Possible bug -layers optimize

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
User avatar
fmw42
Posts: 22105
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

Possible bug -layers optimize

Post by fmw42 » 2017-09-15T20:09:42-07:00

Using both IM 6.9.9.13 Q16 and IM 7.0.7.2 Q16 Mac OSX Sierra, the following command works fine. But when I add -layers optimize, I get a corrupt gif animation.

Input Images: Note the input.gif is coalesced to 1080x1920 and has 77 frames.

http://www.fmwconcepts.com/misc_tests/l ... /image.png
http://www.fmwconcepts.com/misc_tests/l ... /input.gif


Works fine:

Code: Select all

convert image.png null: \( input.gif -coalesce \) -gravity Center -layers composite des.gif
Does not work:

Code: Select all

convert image.png null: \( input.gif -coalesce \) -gravity Center -layers composite -layers optimize des.gif
Does -layers optimize need more memory such that perhaps I am running out?

snibgo
Posts: 9404
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Possible bug -layers optimize

Post by snibgo » 2017-09-15T22:28:50-07:00

On my 12 GB laptop, Windows 8.1, IM v6.9.5-3, your second command took 1.3 GB memory, plus 26 files each 26 MB in %TEMP%. It ran for a few minutes, and I killed it.

I made MPC versions of your files, and ran your first command:

Code: Select all

%IM%convert image.png fmwimage.mpc
%IM%convert input.gif -coalesce fmwinput.mpc

%IM%convert fmwimage.mpc null: ( fmwinput.mpc ) -gravity Center -layers composite  des.gif
convert.exe: memory allocation failed `des.gif' @ error/quantize.c/QuantizeImage/2643.
convert.exe: memory allocation failed `des.gif' @ error/gif.c/WriteGIFImage/1643.
Oddly, it only took 600 MB before failing. Perhaps it then made a huge request for memory. I can't see the problem in the debug output.
snibgo's IM pages: im.snibgo.com

User avatar
magick
Site Admin
Posts: 10691
Joined: 2003-05-31T11:32:55-07:00

Re: Possible bug -layers optimize

Post by magick » 2017-09-16T06:01:33-07:00

Try this command, and be patient. Its pushing pixels to disk so its quite slow:

Code: Select all

convert -define registry:temporary-path=./ -limit memory 16mb image.png null: \( input.gif -coalesce \) -gravity Center -layers composite -layers optimize des.gif

User avatar
fmw42
Posts: 22105
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

Re: Possible bug -layers optimize

Post by fmw42 » 2017-09-16T10:25:12-07:00

Why did my second command run to completion without any error message about "memory allocation failed" but produce a corrupt file.

If it had run out of memory, I would have expected it to have produced some kind of error message!


I tried:

Code: Select all

convert -limit area 0 -debug all image.png null: \( input.gif -coalesce \) -gravity Center -layers composite -layers optimize des2.gif
It ran for nearly 2 minutes and then ended properly with no error message, but still produced a corrupt animated gif

Here is the des2.gif and a debug.txt file with the debug output.

http://www.fmwconcepts.com/misc_tests/l ... g/des2.gif
http://www.fmwconcepts.com/misc_tests/l ... /debug.txt

I have also tried -limit thread 1 and disabling OpenMP in another compile, but they also produce a corrupt gif with the above command.

User avatar
fmw42
Posts: 22105
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

Re: Possible bug -layers optimize

Post by fmw42 » 2017-09-16T15:35:13-07:00

It appears to be a Mac Preview issue. I can open and increment the frame fine in GraphicConvert for the Mac.

Animate also opens the image, but I cannot see enough of it using Xquartz to know if it is animating.

Safari won’t open it. But Firefox plays it just fine.

If I add -resize 50% to both images, it works fine in Mac Preview

Post Reply