Thumbnails from animated images

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
Jeni

Thumbnails from animated images

Post by Jeni »

Hello
I am having an issue with some thumbnails from animated images. You can see here
http://www.hellonturf.com/4image/catego ... p?cat_id=1

Anyone have any idea as to how to fix this?

Thanks
Jeni
pgunther

Re: Thumbnails from animated images

Post by pgunther »

Jen,

Just a question, what is the difference between these two images on your site?

http://www.hellonturf.com/4image/data/t ... _307_2.gif
http://www.hellonturf.com/4image/data/m ... _307_2.gif

The one in the /media seems to be fine.

Pete
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Thumbnails from animated images

Post by anthony »

I thought I responded to this yesterday, but looks like I failed to submit it :-(

Okay this is probably one of the biggest and hardest problems in GIF animation handling, Sorry my updates have not filtered through at the time I write this, so give it a day or two to update.

Problems and Techniques for Reszing Animations
http://www.imagemagick.org/Usage/animations/#resize

Anyone else like to add to, update, contribute examples, disscuss problems and solutions for GIF animation resizing... Now is a good time. Tell your friends.
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: Thumbnails from animated images

Post by anthony »

pgunther wrote: Jen,

Just a question, what is the difference between these two images on your site?

http://www.hellonturf.com/4image/data/t ... _307_2.gif
http://www.hellonturf.com/4image/data/m ... _307_2.gif

The one in the /media seems to be fine.

Pete


From what I can see the first frame was resize with later frames (using transparent or LZW transparency optimizations) did not get resized. The result is a mess!

Hmm animation could be given an interesting variable with the guys head not only nodding, but getting 'blotted'.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Jeni

Re: Thumbnails from animated images

Post by Jeni »

pgunther wrote: Jen,

Just a question, what is the difference between these two images on your site?

http://www.hellonturf.com/4image/data/t ... _307_2.gif
http://www.hellonturf.com/4image/data/m ... _307_2.gif

The one in the /media seems to be fine.

Pete


The only difference is one is the thumbnail and the other is the original image. The first link is the thumbnail.
Jeni

Re: Thumbnails from animated images

Post by Jeni »

Not sure if this helps or not but here is the code I am using.

Code: Select all

 function resize_image_im($src, $dest, $quality, $width, $height, $image_info) {
  global $convert_options;

 $command = $convert_options['convert_path']." -quality ".$quality." -delay 1 -antialias -geometry $width"."x"."$height \"$src\" \"$dest\"";
  system($command);
  return (file_exists($dest)) ? 1 : 0;
}
You will have to excuse me here, but this is all brand new to me so Im learning as Im working, lol.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Thumbnails from animated images

Post by anthony »

Using -geometry was your first BIG mistake.
See IM Examples, Geometry (special purpose resize)
http://www.imagemagick.org/Usage/resize/#geometry

It only resized the last frame of your animation!!!

Use -resize instead..

The next mistake is not handling colors. -anitalias is only for text and drawing, not for reszing images. use -filter point, or use -scale instead of -resize.

Let us know how it goes. I am trying to update the resize area of IM examples, Animations. However al alot of it really has to wait for me to re-write the GIF animations color optimization handling section in Animation Basics.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Jeni

Re: Thumbnails from animated images

Post by Jeni »

Thanks Anthony.

No head way yet. I have take out the geometry and antialis. Ive used resize by itself, scale by iteself, filter point by itself, scale and filter point together, resize and filter point together. I either get the full sized image showing up where the thumbnail should be or I get the default image can not be found icon Image

Not sure what to do now...
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Thumbnails from animated images

Post by anthony »

Can you give the actual origina GIF, and an example command line.

I'll give it a go. If you allow it I may even use it for the IM Examples section :-)
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: Thumbnails from animated images

Post by anthony »

NOTE: it does not seem to have a good time delay. Im animation is really fast for example!

Code: Select all

convert -delay 10 noddy.gif -coalesce -resize 80x80 -layers optimize resized.gif
This worked but while the image is smaller the size is about the same. The reason is probably due to multiple local color tables and other color problems.

Stopping IM adding new colors...

Code: Select all

convert -delay 10 noddy.gif -coalesce -filter point -resize 80x80 -layers optimize scaled.gif
Which is badly aliased as only rows and columns are removed.

Other -filter and -support options may provide a balence between adding new colors, and fuzzyness.

After that color optimizations can reduce sizes further... See the IM Examples Video section.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Jeni

Re: Thumbnails from animated images

Post by Jeni »

So would I have to do this for individual images? I guess it would be best to probably use GD and keep the thumbnails static as there will be numerous (hundreds of images) being uploaded. Gonna be hard to keep track of what would need to be adjusted in IM.

I appreciate the help Anthony.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Thumbnails from animated images

Post by anthony »

Another technique that I did not mention (or write in IM examples yet) is to reduce the colors by using the original animations set of colors as the color map for the resized animation. I have not done any experiments with this however.

If you do come up with an animation that you can allow me to use in IM example, let me know, I can then fill in some of the various techniques with an actual example.

A general thunbnailing proceedure should be posible, though the script may need to 'try' a number of different optimization styles to see what would be the best method to use. However I need a good good animation example to play with, one that does not resize well in general.

The script may also need to be slightly different for different types of animations, that is minimal color cartoons, no transparency, video, etc.

Of course some resizing will just not work at all. For example images that already contain a strong dither, may not work for any resize operation.

I would however like to hear your own views, what you have tried, what works, what didn't.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply