Output of "identify -format %n ..." for animated GIFs has changed in version 0.6.9-4

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
wladekbbb
Posts: 3
Joined: 2015-11-30T09:53:53-07:00
Authentication code: 1151

Output of "identify -format %n ..." for animated GIFs has changed in version 0.6.9-4

Post by wladekbbb »

Animated GIF scaling seems to have broken with version 6.9.0-4 and is still broken in the newest 6.9.2-6. This works correctly between versions 6.8.9-9 and 6.9.0-3.

Example image:
http://vignette1.wikia.nocookie.net/spl ... 0519213343

Command line:

Code: Select all

# (convert is version 6.9.0-3)
$ convert Angry_splendorman_animation_by_gothicraft-d6izfm8.gif -thumbnail 480 test-6.9.0-3.gif
# (convert is version 6.9.0-4)
$ convert Angry_splendorman_animation_by_gothicraft-d6izfm8.gif -thumbnail 480 test-6.9.0-4.gif

Code: Select all

$ ls
-rw-rw-r-- 1 wladek wladek 406559 Nov 27 18:04 Angry_splendorman_animation_by_gothicraft-d6izfm8.gif
-rw-rw-r-- 1 wladek wladek 592601 Nov 27 21:03 test-6.9.0-3.gif
-rw-rw-r-- 1 wladek wladek 638804 Nov 27 20:54 test-6.9.0-4.gif

Code: Select all

$ md5sum *
1a2aed2bb847d5041bdafe16d470baba  Angry_splendorman_animation_by_gothicraft-d6izfm8.gif
e3e5b3da73619557f2bda486f4160256  test-6.9.0-3.gif
bbeb543b1426c959ea857c6c85766f21  test-6.9.0-4.gif

Identify on test-6.9.0-3.gif shows the following output:

Code: Select all

$ identify test-6.9.0-3.gif
test-6.9.0-3.gif[0] GIF 480x480 480x480+0+0 8-bit sRGB 256c 593KB 0.000u 0:00.000
test-6.9.0-3.gif[1] GIF 89x113 480x480+241+110 8-bit sRGB 256c 593KB 0.000u 0:00.000
test-6.9.0-3.gif[2] GIF 87x105 480x480+241+116 8-bit sRGB 256c 593KB 0.000u 0:00.000
test-6.9.0-3.gif[3] GIF 56x25 480x480+239+195 8-bit sRGB 256c 593KB 0.000u 0:00.000
test-6.9.0-3.gif[4] GIF 58x27 480x480+239+193 8-bit sRGB 256c 593KB 0.000u 0:00.000
test-6.9.0-3.gif[5] GIF 424x298 480x480+38+84 8-bit sRGB 256c 593KB 0.000u 0:00.000
test-6.9.0-3.gif[6] GIF 427x298 480x480+27+84 8-bit sRGB 256c 593KB 0.000u 0:00.000
test-6.9.0-3.gif[7] GIF 446x302 480x480+27+83 8-bit sRGB 256c 593KB 0.000u 0:00.000
test-6.9.0-3.gif[8] GIF 457x337 480x480+23+83 8-bit sRGB 256c 593KB 0.000u 0:00.000
test-6.9.0-3.gif[9] GIF 480x397 480x480+0+83 8-bit sRGB 256c 593KB 0.000u 0:00.000
test-6.9.0-3.gif[10] GIF 480x441 480x480+0+39 8-bit sRGB 256c 593KB 0.000u 0:00.000
test-6.9.0-3.gif[11] GIF 480x443 480x480+0+37 8-bit sRGB 256c 593KB 0.000u 0:00.000
test-6.9.0-3.gif[12] GIF 480x445 480x480+0+35 8-bit sRGB 256c 593KB 0.000u 0:00.000
test-6.9.0-3.gif[13] GIF 480x445 480x480+0+35 8-bit sRGB 256c 593KB 0.000u 0:00.000
test-6.9.0-3.gif[14] GIF 480x443 480x480+0+37 8-bit sRGB 256c 593KB 0.000u 0:00.000
test-6.9.0-3.gif[15] GIF 480x441 480x480+0+39 8-bit sRGB 256c 593KB 0.000u 0:00.000
test-6.9.0-3.gif[16] GIF 480x397 480x480+0+83 8-bit sRGB 256c 593KB 0.000u 0:00.000
test-6.9.0-3.gif[17] GIF 457x337 480x480+23+83 8-bit sRGB 256c 593KB 0.000u 0:00.000
test-6.9.0-3.gif[18] GIF 446x301 480x480+27+84 8-bit sRGB 256c 593KB 0.000u 0:00.000
test-6.9.0-3.gif[19] GIF 439x298 480x480+27+84 8-bit sRGB 256c 593KB 0.000u 0:00.000
Identify on test-6.9.0-4.gif shows the following output:

Code: Select all

$ identify test-6.9.0-4.gif
test-6.9.0-4.gif[0] GIF 480x480 480x480+0+0 8-bit sRGB 256c 639KB 0.000u 0:00.010
test-6.9.0-4.gif[1] GIF 480x626 480x480+0+0 8-bit sRGB 256c 639KB 0.000u 0:00.010
test-6.9.0-4.gif[2] GIF 480x590 480x480+0+0 8-bit sRGB 256c 639KB 0.000u 0:00.000
test-6.9.0-4.gif[3] GIF 480x202 480x480+0+0 8-bit sRGB 256c 639KB 0.000u 0:00.000
test-6.9.0-4.gif[4] GIF 480x219 480x480+0+0 8-bit sRGB 256c 639KB 0.000u 0:00.000
test-6.9.0-4.gif[5] GIF 480x336 480x480+0+0 8-bit sRGB 256c 639KB 0.000u 0:00.000
test-6.9.0-4.gif[6] GIF 480x334 480x480+0+0 8-bit sRGB 256c 639KB 0.000u 0:00.000
test-6.9.0-4.gif[7] GIF 480x324 480x480+0+0 8-bit sRGB 256c 639KB 0.000u 0:00.000
test-6.9.0-4.gif[8] GIF 480x352 480x480+0+0 8-bit sRGB 256c 639KB 0.000u 0:00.000
test-6.9.0-4.gif[9] GIF 480x395 480x480+0+0 8-bit sRGB 256c 639KB 0.000u 0:00.000
test-6.9.0-4.gif[10] GIF 480x440 480x480+0+0 8-bit sRGB 256c 639KB 0.000u 0:00.000
test-6.9.0-4.gif[11] GIF 480x442 480x480+0+0 8-bit sRGB 256c 639KB 0.000u 0:00.000
test-6.9.0-4.gif[12] GIF 480x444 480x480+0+0 8-bit sRGB 256c 639KB 0.000u 0:00.000
test-6.9.0-4.gif[13] GIF 480x444 480x480+0+0 8-bit sRGB 256c 639KB 0.000u 0:00.000
test-6.9.0-4.gif[14] GIF 480x442 480x480+0+0 8-bit sRGB 256c 639KB 0.000u 0:00.000
test-6.9.0-4.gif[15] GIF 480x440 480x480+0+0 8-bit sRGB 256c 639KB 0.000u 0:00.000
test-6.9.0-4.gif[16] GIF 480x395 480x480+0+0 8-bit sRGB 256c 639KB 0.000u 0:00.000
test-6.9.0-4.gif[17] GIF 480x352 480x480+0+0 8-bit sRGB 256c 639KB 0.000u 0:00.000
test-6.9.0-4.gif[18] GIF 480x323 480x480+0+0 8-bit sRGB 256c 639KB 0.000u 0:00.000
test-6.9.0-4.gif[19] GIF 480x325 480x480+0+0 8-bit sRGB 256c 639KB 0.000u 0:00.000
As we can see above the updated area differs between frames and in the version 6.9.0-4 and newer the updated area is incorrectly scaled to the full width of the requested thumbnail while it should stay relative to the image dimensions (as it does in version 6.9.0-3 and older).

Please let me know if the description is clear or I should add more information in this bug report.
Last edited by wladekbbb on 2015-12-01T08:28:10-07:00, edited 3 times in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Animated GIF scaling is broken in version 0.6.9-4 and newer

Post by fmw42 »

I get a corrupted image with your command in IM 6.9.2.7 Q16 Mac OSX. But coalescing and optimizing again gives good results.

Code: Select all

convert Angry_splendorman_animation_by_gothicraft-d6izfm8.gif -coalesce -thumbnail 480 -layers optimize test2.gif

Code: Select all

identify test2.gif

test2.gif[0] GIF 480x480 480x480+0+0 8-bit sRGB 256c 566KB 0.000u 0:00.000
test2.gif[1] GIF 89x113 480x480+241+110 8-bit sRGB 256c 566KB 0.000u 0:00.000
test2.gif[2] GIF 87x105 480x480+241+116 8-bit sRGB 256c 566KB 0.000u 0:00.000
test2.gif[3] GIF 56x25 480x480+239+195 8-bit sRGB 256c 566KB 0.000u 0:00.000
test2.gif[4] GIF 58x27 480x480+239+193 8-bit sRGB 256c 566KB 0.000u 0:00.000
test2.gif[5] GIF 424x298 480x480+38+84 8-bit sRGB 256c 566KB 0.000u 0:00.000
test2.gif[6] GIF 427x298 480x480+27+84 8-bit sRGB 256c 566KB 0.000u 0:00.000
test2.gif[7] GIF 446x302 480x480+27+83 8-bit sRGB 256c 566KB 0.000u 0:00.000
test2.gif[8] GIF 457x337 480x480+23+83 8-bit sRGB 256c 566KB 0.000u 0:00.000
test2.gif[9] GIF 480x397 480x480+0+83 8-bit sRGB 256c 566KB 0.000u 0:00.000
test2.gif[10] GIF 480x441 480x480+0+39 8-bit sRGB 256c 566KB 0.000u 0:00.000
test2.gif[11] GIF 480x443 480x480+0+37 8-bit sRGB 256c 566KB 0.000u 0:00.000
test2.gif[12] GIF 480x445 480x480+0+35 8-bit sRGB 256c 566KB 0.000u 0:00.000
test2.gif[13] GIF 480x445 480x480+0+35 8-bit sRGB 256c 566KB 0.000u 0:00.000
test2.gif[14] GIF 480x443 480x480+0+37 8-bit sRGB 256c 566KB 0.000u 0:00.000
test2.gif[15] GIF 480x441 480x480+0+39 8-bit sRGB 256c 566KB 0.000u 0:00.000
test2.gif[16] GIF 480x397 480x480+0+83 8-bit sRGB 256c 566KB 0.000u 0:00.000
test2.gif[17] GIF 457x337 480x480+23+83 8-bit sRGB 256c 566KB 0.000u 0:00.000
test2.gif[18] GIF 446x301 480x480+27+84 8-bit sRGB 256c 566KB 0.000u 0:00.000
test2.gif[19] GIF 439x298 480x480+27+84 8-bit sRGB 256c 566KB 0.000u 0:00.000
wladekbbb
Posts: 3
Joined: 2015-11-30T09:53:53-07:00
Authentication code: 1151

Re: Animated GIF scaling is broken in version 0.6.9-4 and newer

Post by wladekbbb »

Thanks for a prompt response.

tl;dr Output of "identify -format %n" has changed for animated gifs in 6.9.0-4.

I investigated the issue further and found the underlying problem. Apparently I simplified the command
line arguments as I wanted to make the bug report concise and without an unnecessary noise but failed
at doing this right. So the longer story follows.

We have a script that builds parameter list and the crucial part is this one:
(echos added for debugging)

Code: Select all

function is_animated() {
        echo $IDENTIFY -format "%n" "$1"
        num=$($IDENTIFY -format "%n" "$1")
        echo $num
        if [[ $num -gt 1 ]]; then
                return 1
        else
                return 0
        fi
}
based on that there are some extra parameters added including "-coalesce -layers Optimize"

And when using imagemagick version 6.9.0-3 prints:

Code: Select all

/home/wladek/dev/imagemagick/ImageMagick-6.9.0-3/utilities/identify -format %n Angry_splendorman_animation_by_gothicraft-d6izfm8.gif
20
the parameters are added.

On the other hand with version 6.9.0-4 the script prints:

Code: Select all

/home/wladek/dev/imagemagick/ImageMagick-6.9.0-4/utilities/identify -format %n Angry_splendorman_animation_by_gothicraft-d6izfm8.gif
2020202020202020202020202020202020202020
(number 20 is repeated 20 (=number of frames?) times)
and then test fails to interpret this as a number

Code: Select all

$ test 20 -gt 1 ; echo $?
0
$ test 2020202020202020202020202020202020202020 -gt 1 ; echo $?
bash: test: 2020202020202020202020202020202020202020: integer expression expected
2
which basically skips (in some other part of the script) adding those parameters you mentioned.

So my question now becomes:
Is the new output from identify a desired new behavior or a bug?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Output of "identify -format %n ..." changed in version 0.6.9-4

Post by fmw42 »

Is the new output from identify a desired new behavior or a bug?
I cannot say, but it has been this way for some time. You are getting the total number of frames for each frame in the image.

But you can get the result you want on unix systems by

Code: Select all

identify -format "%n\n" yourimage | head -n 1
And it should not affect your result on older systems.
wladekbbb
Posts: 3
Joined: 2015-11-30T09:53:53-07:00
Authentication code: 1151

Re: Output of "identify -format %n ..." for animated GIFs has changed in version 0.6.9-4

Post by wladekbbb »

Yes, that works. I'm gonna stick with it for now.

However I still think it's worth for you to check if the change in the output content is a desired change or a bug.
Anyway thanks for the short response time and working solution.
Post Reply