chanlleging problem, split gif easily ,no way to recombine

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
gefferey

chanlleging problem, split gif easily ,no way to recombine

Post by gefferey »

Image

i have used convert "spring festival.gif" sf_%d.gif to split it, but when i want to recombine them ,i could not get the original result, i dont know why. and i use convert "spring festival.gif" -coalesce +adjoin sf_%d.gif ,i get different gifs from the above ,and also i could not recombine them to get the orginal one. can anyone help me out ?

i tried to watermark this gif, use "convert sf.gif -coalesce -gravity center -geometry +0+0 null: -draw "gravity north fill black text 0,12 'copyright'" -layers composite -layers optimize wmark_sf.gif" but error happens:Magick: missing Null Image List Separator layers Composite @ error/mogrify.c/MogrifyImageList/8121. and i see the output wmark_sf.gif is totally different from the original one. i dont know why
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: chanlleging problem, split gif easily ,no way to recombi

Post by fmw42 »

IM 6.6.4.10 Q16 (hdri) Mac OSX Tiger


I can verify that doing

convert spring_festival.gif -coalesce spring_festival_%d.gif

gives bad results for frames 1,2,3, but correct results for frame 0.


If I do the following I get a colormap error. So perhaps your image is corrupt in some way.

convert spring_festival.gif spring_festival_c.gif
convert: invalid colormap index `spring_festival.gif' @ error/colormap-private.h/ConstrainColormapIndex/34.


This works successfully, but all but the first frame are bad as described above (mostly red).

I am not an expert on gif format, but perhaps you should report this on the bugs forum. Or perhaps some one with more knowledge about gif animations might take a look and answer, such as Anthony.
gefferey

Re: chanlleging problem, split gif easily ,no way to recombi

Post by gefferey »

i got the first frame correctly too, the other three are mostly red and incorrectly. thank u for ur help
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: chanlleging problem, split gif easily ,no way to recombi

Post by fmw42 »

I also get the same bad results going to png

convert spring_festival.gif -coalesce spring_festival_%d.png
gefferey

Re: chanlleging problem, split gif easily ,no way to recombi

Post by gefferey »

when i use ulead animator to split the gif, i got the correct four frames, i dont know why.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: chanlleging problem, split gif easily ,no way to recombi

Post by fmw42 »

I suspect that ulead is not making a correct colormap, per the example above of a simple convert and the error message.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: chanlleging problem, split gif easily ,no way to recombi

Post by anthony »

I also see a good first frame and back later frames. this is nothing to do with coalesce, but with the GIF reading itself.

Using a old format specific program "giftrans"....

Code: Select all

 giftrans -L spring_festival.gif
Animation has a global color table of 16 colors, with no transparent flag set for the first frame.

But then uses a Transparent color index (16) for the 3 later frames!

The problem is not with -coalesce but with IM GIF reading. The GIF coder is not handling a global color table with transparency off with later images that use that same color table, and transparency on.

Or perhaps the result is being overlayed on the normally unused background color (color index 0)

---------------------

This is the SAME bug I have reported (three times so far) with GIF reading, for the last few years.


That is when the GIF image (actually written by imageMagick this time) contains no transparency on the first frame and has transparency in later frames, IM fails to read it back into memory correctly...

For example...

First create a "Dispose Background" test animation

Code: Select all

  convert -delay 100 -dispose none \
                -size 100x100 xc:SkyBlue +antialias \
                -fill DodgerBlue -draw 'circle 50,50 15,25' \
          -dispose background \
                -page +5+10  balloon.gif  \
                -page +35+30 medical.gif  \
                -page +62+50 present.gif  \
                -page +10+55 shading.gif  \
          -loop 0  canvas_bgnd.gif
Now make a -layers Dispose version

Code: Select all

convert  canvas_bgnd.gif -layers Dispose canvas_bgnd_dispose.gif
This animation works perfectly.... Showing transparency...
Image

But if IM tried to read it (and write it again), all the transparency disappears!!!!

Code: Select all

convert canvas_bgnd_dispose.gif canvas_bgnd_dispose_rw.gif
Image

The problem is ONlY in GIF reading, as after reading the images in memory (all fully coalesce already) do not show the transparency they should! As it displays correctly the write part of GIF coder is correct, in it only the READ that is failing.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
gefferey

Re: chanlleging problem, split gif easily ,no way to recombi

Post by gefferey »

thx a lot . this problem confused me for a long time ,and now i know why.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: chanlleging problem, split gif easily ,no way to recombi

Post by anthony »

Adendum... I al see an error that should not exist...

Code: Select all

convert spring_festival.gif t.gif
convert: invalid colormap index `spring_festival.gif' @ error/colormap-private.h/ConstrainColormapIndex/34.
this may be the best indication as to the transparency into global colormap problem.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: chanlleging problem, split gif easily ,no way to recombi

Post by anthony »

I found that 'gifsicle', a very old GIF optimizer also generated the same wrong result!!!
The same goes for "gifview".

The question is why, when the web browser obviously gets it right!


Closer look....

The global color table in both images is exactly a power of 2.
16 for spring_festivel.gif and 2 for canvas_bgnd_dispose.gif
However the transparent color index is 16 and 2 respectively.

As such while these animations will display correctly, the actual color index for transparency does not actually point to a real color in the color table.

It may be that either the transpareny color index needs to ignore 'high bits' in which case the color index to use is '0' in both cases. Though I doubt that is correct.

OR the image data in GIF is using 8 bit indexes (one byte per pixel whne uncompressed) regardless of the color table, and just because transparency points to a non-existant color table entry does not make it an invalid color index. -- ANY ONE KNOW THE GIF SPECIFICATION?

That is the image data contains transparent indexes, but the color table does not, because the first image did not need it and it was a power of two in size already!

In any case it is obvious that the firefox browser understands this, even if ImageMagick, gifsicle, and gifview does not.


So the problem is multi-fold.
  • A read problem: handling a transparent index outside colortable size
  • A IM write problem: generating a invalid transparent index for too small a global colortable.
  • Unless of course transparent indexes can be 'invalid'! After all you don't really need to have a valid transparent color, just a transparent index!
What created the "spring_festival.gif" image in the first place?

Do you have a valid source image somewhere?
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
gefferey

Re: chanlleging problem, split gif easily ,no way to recombi

Post by gefferey »

i dont have the source image, i downloaded the gif from the internet. it is really complicate problems as i know little about the colormap, but thank you very much for ur patience.
Post Reply