header image
digital-photo-software-guide.com

Resize gif images
the pros and cons



When you want to resize gif images,  you may think about resampling them because resampling images gives better results than only resizing images. So how to resample gifs and what are the problems encountered?

Basically gif images can not be resampled. Period.

Ok let's go on, the page is not over, there is a lot to comment about resizing and resampling gifs.  Because most people will try it -me too- even it is not advisable in most cases.

Applying a resample algorithm needs a 24 bit color depth image -a 16 million color image-  A gif image is at best an 8 bit color depth image -a 256 color image-

The step is easy, you can resize gif images through a resampling algorithm if you transform your gif image into a 24 bit color depth image -16 million colors- first!

You can transform your gif to 16 millions colors either:
bullet  Explicitly if your image editor has a function that allows you to modify the color depth  -but if you save it as a gif, it will be back-transformed to 256 colors(!)-
bullet  Or implicitly by opening your gif image with your image editor and subsequently saving it as a jpg image.

Now let's talk about the content of your image. Is it a photo?
bullet  Yes. Then I may ask you "why was it saved as a gif?" Ok, you did not decide about it yourself, you got it somewhere.  Going up to 24 bit color depth is a good idea. Resampling it is a good idea too.

But going the way back to 8 bit color depth after you resize/resample it, I don't know...  I think you would better keep it as a jpg or a png and NOT go back to a gif.

bullet  No. It is a graphic with few colors -let's say 10, 20, 40 colors-.  Then gif was a fitting format for your image. But png would be too :-).
Ok, you did transform it to jpg -i.e. open the gif and save it as jpg- and you did resample it.

THE problem is that now your image does not need 10 or 20 colors among the 256 colors available in the gif format,  BUT 25000 colors (e.g.) among the 16 millions colors available in the jpg format.

Resampling did smooth some edges and thus a lot of additional colors are necessary!

Now you can go back. You can reduce the color depth to 256 colors.  Probably you won't even see a loss of quality because the 25 000 colors are reduced to the best matching 256 colors.  But the resulting gif file may be bigger in kilobytes even if you did reduce the width and height of your image while resampling it!

info How to go back to 256 colors?
bullet  Either explicitly, if your image editor has a function that allows you to modify the color depth.  In this case you may have to select a method among a few methods offered and results are good if you select the appropriate method.
bullet  Or implicitly by just saving your image as a gif image.  Many image editors will produce an ugly result this way.

When reducing the color depth explicitly you may choose a palette:
- standard palette
- median optimized palette
- octree optimized palette...

and a reduction method:
- nearest color
- error diffusion

Error diffusion will mostly produce a bigger file size, but the palette choice is less important.  Nearest color with median optimized palette -or eventually octree- is optically better and files should be smaller.  Nearest color with standard palette is not recommended.

Going the way of increasing the color depth, resampling and decreasing the color depth to resize gif images will mostly produce bigger files for the reduced image. If your original wish was to get a smaller file to publish on a web page, that was not a success!

Another idea? Just resizing the gif -NOT resampling it-.  Yes, ok, may be, we said it is a graphic not a photo.  Resizing it will keep it sharp, no smoothed edges, BUT we will lose many pixels when we reduce the size.  Words and characters may probably be unreadable...

Here is an example
Original screenshot
   -> 408 x 305 pixels
   -> 61 colors used of 256 colors available
   -> file size 9831 bytes
original screenshot

Resize gif image example
Resized to 75%
   -> 306 x 229 pixels
   -> 60 colors used of 256 colors available
   -> file size 6273 bytes
resized
Comment: the image is smaller, the file is smaller too.  Most words are not readable anymore. The 3rd dotted line has completely disappeared.

Resample gif image example
Color depth modified to 16 millions colors
Resampled to 75% (bilinear algorithm)
   -> 306 x 229 pixels
   -> 1204 colors used of 16 millions colors available
Color depth re-modified to 256 colors
   -> 235 colors used of 256 colors available
   -> file size 10272 bytes
resampled
Comment: the image is smaller, the file is BIGGER!  Words are readable, but slightly blured.


My conclusion is that I decided I will avoid to resize or resample gifs if ever possible, because in most cases it is a headache.  And if for any reason I nevertheless want to resize or resample a gif,  I will at least keep the result in another format and will not go back to gif with the resized image.




Page tested with Opera, Epiphany, Konqueror, Firefox, Netscape and MSIE.
Copyright © 2003-2010 digital-photo-software-guide.com, All rights reserved.