Page 1 of 2
stubborn composite null image issue
Posted: 2011-02-16T20:00:08-07:00
by goyop
Hi all,
Have several video capture and near real time processing machines. IM is a big help due to its power and speed so that we can keep processing times as low as possible. On some images we need to overlay a mask so we use the composite function. I have it working fine on one system but now am needing to integrate the overlay feature on another system and it just won't fly.
- Hardware wise we have similar systems running Intel Atom processors with Embedded XP
- I am using the composite for a MJPEG file of less than 100 frames being combined with one PNG image as an overlay
- The system that works OK has 6.5.5-Q16 and the system that is not working has 6.5.1. I can upgrade if will solve the problem but the machine is remote and in operation 24/7. If anything hangs or causes the current scripts to not work then we will have to go to the remote location and manage it there which is less than ideal. But if that is the issue then it must be done.
The problematic line is:
imconvert map_A%%03d.jpg null: p_k_mask.png -layers Composite map_A_MASK%%03d.jpg
It returns the following:
missing null image list separator layers -composite
The code before this line is a crop, repage, resize, and scene commands. They work fine. Also, we are using the composite command on another system with no problem. Any ideas?
Thanks,
Greg
Re: stubborn composite null image issue
Posted: 2011-02-16T20:27:58-07:00
by anthony
For some reason
-layers composite is not seeing the null: image in the provided image sequence, so as to separate destination image from the source image.
I do not know why it is not finding it. How may images do you have.
Is this the exact command you are using?
Alturnative if the mask is the same size is to invert the source and destination image order.
As you are using JPG image you obviously do not care about any animation meta-data.
Code: Select all
imconvert p_k_mask.png null: map_A%%03d.jpg \
-compose Dst_over -layers Composite map_A_MASK%%03d.jpg
WARNING: do not save and read JPEG images constantally. That is a lossy file format repeated read and writes will degrade the image quality. This is a aspect of using JPEG, not of IM.
See
http://www.imagemagick.org/Usage/formats/#jpg
And more specifically and in-depth...
http://photo.net/learn/jpeg/
Re: stubborn composite null image issue
Posted: 2011-02-17T14:37:05-07:00
by goyop
Anthony,
I tried your suggestions and a few others but still getting the null image error. I have a small RAR file with 10 jpgs, 1 PNG, and one line of script that I was going to attach to this for review. Please let me know how to send an attachment if possible.
Thanks,
Greg
Re: stubborn composite null image issue
Posted: 2011-02-17T14:48:45-07:00
by fmw42
goyop wrote:Anthony,
I tried your suggestions and a few others but still getting the null image error. I have a small RAR file with 10 jpgs, 1 PNG, and one line of script that I was going to attach to this for review. Please let me know how to send an attachment if possible.
Thanks,
Greg
The forum does not have any direct mechanism for sending files. What you need to do is host your images or compressed file (usually a zip is more universal across platforms) somewhere with public access and then provide a link to where it is hosted such that it can then be downloaded.
Re: stubborn composite null image issue
Posted: 2011-02-17T16:00:17-07:00
by goyop
The folder with files can be accessed at
http://members.cox.net/gpmonline/test%20mask.rar
Thanks,
Greg
Re: stubborn composite null image issue
Posted: 2011-02-17T16:00:30-07:00
by fmw42
Greg,
I got the RAR you sent me. Zip would have been better as I had to save each image separately and renamed them. I put them all into a folder and cd to that folder for simplicity.
Here is the filelist:
map_000.jpg
map_001.jpg
map_002.jpg
map_003.jpg
map_004.jpg
map_005.jpg
map_006.jpg
map_007.jpg
map_008.jpg
map_009.jpg
mask.png
Keep in mind I am on a rather old Mac with an old version of bash (don't know if that matters). IM 6.6.7.7 Q16 Mac OSX Tiger
I tried
cd to folder
convert map_%03d.jpg null: mask.png -layers Composite map_mask_%03d.jpg
convert: missing Null Image List Separator layers Composite @ error/mogrify.c/MogrifyImageList/8149.
I am not sure my system can read %03d as wild cards for input. Perhaps Anthony can clarify further.
So then I tried
convert map_*.jpg null: mask.png -layers Composite map_mask_%03d.jpg
That worked perfectly with no errors and the images look fine.
map_mask_000.jpg
map_mask_001.jpg
map_mask_002.jpg
map_mask_003.jpg
map_mask_004.jpg
map_mask_005.jpg
map_mask_006.jpg
map_mask_007.jpg
map_mask_008.jpg
map_mask_009.jpg
Fred
Re: stubborn composite null image issue
Posted: 2011-02-17T16:16:30-07:00
by goyop
Fred,
You rock! It is working. The filenames are created by a -scene command in order to process them in sequence to create an AVI file. So apparently the composite command doesn't like seeing that as evidenced by the wildcard you inserted.
Back when I was at university studying engineering my introduction to programming was by writing a program, typing up the commands on IBM punch cards, then loading the cards into a compiler and executing the program. We were using Fortran. From there it was hours of hunting down syntax issues on all the "Fatal Errors" or endless loops. That is when I decided that programming was not going to be my career. However there is no way around a certain amount of programming which I reluctantly embrace. My first job was assembly language programming of the Z8000! (For all the youngsters here just google all the strange words)
Anyhow, I am thankful for this forum and the good people here who help the programming challenged.
Greg
Re: stubborn composite null image issue
Posted: 2011-02-17T16:39:45-07:00
by fmw42
Well I for one would like to understand why it works on one of your computers and not the other. I suspect the OS/environment has something to do with whether you can use %03d for input image wild cards.
Hopefully Anthony will be able to clarify whether this is an OS or IM issue?
The page at
http://www.imagemagick.org/script/comma ... essing.php seems to imply that both methods should work:
Two quotes from that page:
1)
Filename Globbing
In Unix shells, certain characters such as the asterisk (*) and question mark (?) automagically cause lists of filenames to be generated based on pattern matches. This feature is known as globbing. ImageMagick supports filename globbing for systems, such as Windows, that does not natively support it. For example, suppose you want to convert 1.jpg, 2.jpg, 3.jpg, 4.jpg, and 5.jpg in your current directory to a GIF animation. You can conveniently refer to all of the JPEG files with this command:
$magick> convert *.jpg images.gif
2)
Another method of referring to other image files is by embedding a formatting character in the filename with a scene range. Consider the filename image-%d.jpg[1-5]. The command
$magick> convert image-%d.jpg[1-5]
causes ImageMagick to attempt to read images with these filenames:
image-1.jpg
image-2.jpg
image-3.jpg
image-4.jpg
image-5.jpg
_____________________
By the way, my only formal computer class was also Fortran (and punch cards) - so that dates me also.
Re: stubborn composite null image issue
Posted: 2011-02-17T19:02:42-07:00
by anthony
fmw42 wrote:I am not sure my system can read %03d as wild cards for input. Perhaps Anthony can clarify further.
See IM Read Modifiers..
http://www.imagemagick.org/Usage/files/# read_frames
Basically IM will start with the number 0 and format it according to the % printf expression.
It will then attempt to read that filename. It then increments the number and reads the next filename.
when it fails to read a file, it stops.
You can special a specific number range, such as
'image_%03.png[5-10]' which will read files image_005.png thru to image_010.png in sequence. You can also skip ranges or read individual image numbers.
Re: stubborn composite null image issue
Posted: 2011-02-17T19:10:16-07:00
by anthony
I am not certain why null: was not found in one instance and not in the other. The programming for this is straight forward.
Loop though the image list until the special 'null:' image is found (Images CODER=null) and either error is not found, or break list into two image sequences at that point for Layer Composite Processing (with needs two separate image lists!
It is just strange to me it was not found! The re-ordering just placed the null: image as the second image, rather than the second last image so it will be found sooner.
It sounds like something is failing to link up the image sequence correctly, but only on that specific system. will be very hard to track down such as bug, especially as the re-ordering worked perfectly.
Re: stubborn composite null image issue
Posted: 2011-02-17T20:05:08-07:00
by anthony
I downloaded the rar archive. Saving filenames map_A001.jpg to map_A010.jpg.
reading the files...
Code: Select all
montage map_A%03d.jpg'[1-10]' show:
Shows the images read fine. Note you must specify the right number format, and as the images start at 1 you need to give a range.
Renameing to start at 0 (using a personal script "
mv_reseq -0 map_*") and this failed...
But this worked
Code: Select all
montage map_A%03d.jpg'[0-9]' show:
It looks like you MUST supply a range for it to work
http://www.imagemagick.org/Usage/files/read_frames
This might be classed as a bug. But in any case teh mystery of that is solved. NEXT
Re: stubborn composite null image issue
Posted: 2011-02-17T20:08:59-07:00
by anthony
getting back the origina images from the RAR map_A001.jpg to map_A010.jpg
This worked perfectly for me...
convert map_A*.jpg null: p_k_mask.png -layers composite miff: | montage - -geometry +2+2 show:
It may be the 'no null:' error is when no images were read. In other words the %03d failed as there was no 'read frame read modifier' present. (see previous post)
Re: stubborn composite null image issue
Posted: 2011-02-17T20:13:39-07:00
by fmw42
Thanks Anthony!
Your solution also works for me:
convert map_%03d.jpg[0-9] null: mask.png -layers Composite map_mask_%03d.jpg
and even this works to produce all the correct number of images even though I specified too many and got error messages as is appropriate. But it worked to make 0-9 correctly
convert map_%03d.jpg[0-11] null: mask.png -layers Composite map_mask_%03d.jpg
convert: unable to open image `map_010.jpg': No such file or directory @ error/blob.c/OpenBlob/2588.
convert: unable to open image `map_011.jpg': No such file or directory @ error/blob.c/OpenBlob/2588.
Re: stubborn composite null image issue
Posted: 2011-02-17T20:16:24-07:00
by anthony
It may be that the %d in input file needs a little more work to allow for a default - no field modifier - method.
Re: stubborn composite null image issue
Posted: 2011-02-17T20:18:58-07:00
by fmw42
I tried this, but it did not work fully:
convert map_%03d.jpg[0--1] null: mask.png -layers Composite map_mask_%03d.jpg
So your suggestion of some method to get them all without specifying the exact range would be useful.
Is %d an IM construct or a unix construct?