ravel wrote:Hi anthony,
thanks for the quick answer. the result is great!
You are right when you say the gif is created in a very unoptimized way. Hence I want to create the gif with IM.
I found an example for creating an animated gif with IM. The result was about the same like my approach creating the GIF without IM.
Here is the source image:
http://img3.imagebanana.com/img/u44c84vr/wow.jpg
I found the animated gif creating code here (last example on the page):
http://www.ioncannon.net/linux/81/5-ima ... es-part-1/
This is my code for creating the animated gif:
Code: Select all
convert c:\wow.jpg -font Arial -fill white -pointsize 20 -annotate +50+50 "Frame 1" wow_frame1.gif
convert c:\wow.jpg -font Arial -fill white -pointsize 20 -annotate +50+50 "Frame 2" wow_frame2.gif
convert c:\wow.jpg -font Arial -fill white -pointsize 20 -annotate +50+50 "Frame 3" wow_frame3.gif
convert c:\wow.jpg -font Arial -fill white -pointsize 20 -annotate +50+50 "Frame 4" wow_frame4.gif
convert -delay 100 -page +0+0 wow_frame1.gif -page +0+0 wow_frame2.gif -page +0+0 wow_frame3.gif -page +0+0 wow_frame4.gif -loop 0 c:/wow_animation.gif
Result: 248 kb size.
What am i doing wrong?
Thanks,
ravel
First you can improve the result by changing from GIF intermediate images to PNG. the image format does not matter as long as it is not lossy (GIF and JPEG are lossy formats, they loose and change the image when saving due to the format specification).
as you are not saving with any offsets, the format does not need to be special. Any non-lossy image format will do.
Code: Select all
convert c:\wow.jpg -font Arial -fill white -pointsize 20 -annotate +50+50 "Frame 1" wow_frame1.png
convert c:\wow.jpg -font Arial -fill white -pointsize 20 -annotate +50+50 "Frame 2" wow_frame2.png
convert c:\wow.jpg -font Arial -fill white -pointsize 20 -annotate +50+50 "Frame 3" wow_frame3.png
convert c:\wow.jpg -font Arial -fill white -pointsize 20 -annotate +50+50 "Frame 4" wow_frame4.png
convert -delay 100 wow_frame[1-4].png -loop 0 c:\wow_animation.gif
that simple change => 255461 bytes
Optimize
Code: Select all
convert c:\wow_animation.gif -layers optimize c:\wow_anim_opt.gif
and you get 199037 bytes
But that still is not so good.
That is due to 'dither' failures, again because it was saved to a lossy format BEFORE the frame optimization was performed. To avoid that I replaced that final step in the first set of commands with...
Code: Select all
convert -delay 100 wow_frame[1-4].png -layers optimize -loop 0 c:\wow_anim_opt2.gif
so that its is optiomized BEFORE being saved to GIF for the first time.
Size is now 64297 bytes, and no 'fuzz factor' was required as the color differences from one frame to the next was exact!
Even better, use the techniques simular to that shown in IM examples (which is probbaly a lot better than the docs you were using) for modifying frames,
http://www.imagemagick.org/Usage/anim_mods/#frame_mod
to create the WHOLE animation in one command!
Code: Select all
convert -delay 100 c:\wow.jpg \
-font Arial -fill white -pointsize 20 \
\( -clone 0 -annotate +50+50 "Frame 1" \) \
\( -clone 0 -annotate +50+50 "Frame 2" \) \
\( -clone 0 -annotate +50+50 "Frame 3" \) \
\( -clone 0 -annotate +50+50 "Frame 4" \) \
-delete 0 -layers optimize \
-loop 0 c:\wow_anim_opt2.gif
No intermediate frames, not dither or color differences, and even a nicely color dithered constant background that does not even have the color banding that was present on the original animation example you gave. Just a clean well optimized static background with writing on each and every frame.
NOTE: my own examples will be a little larger than what you will get due to a 'annotate slew' bug that is present in my current the beta release version of ImageMagick.
ASIDE: see IM Examples, API, Window DOS scripts for some techniques on how to convert my Linux shell style to DOS
http://www.imagemagick.org/Usage/api/#windows