Page 1 of 2

Reduce gif file size (tried optimize, optimizePlus, deconst)

Posted: 2009-03-16T07:34:05-07:00
by QooooQ
Hey guys,
I need help.

Edit
Was allowed to make files public.
This animated gif is produced by Fireworks. It has 28 KB and looks gread
This animated miff is produced by ImageMagick. I can only reduce it to a 64 KB GIF, but this is to much. It needs to get near 30 KB.
Can someone help ?!

Made a bannergenerator for my work, that uses ImageMagick.
  • * 5 different banners are created.
    * All having same elements with different arrangement.
    * Width and Height also vary ('120x240','120x600','300x250','468x60','728x90')
    * With 8 Frames min and 11 Frames max.
    * Smallest size without optimization is 80 KB, biggest size is 120 KB
    * Best found optimization technique reduces smallest to 52 KB, biggest to 68 KB looking really crappy (edges are zickzacked)
When I use Fireworks I can easily reduce the biggest banner to 28 KB with 32 colors but still a wunderfull quality. Well and this is my bos's wish, or at least 40 KB, cause this banners will be pulled very often in future. But I can only reach 80 KB without making the quality to bad.

here are the techniques I tried.
  • * "convert $completeMiff -deconstruct $optimizedFile"
    * "convert $completeMiff -deconstruct -layers optimize $optimizedFile_2"
    * "convert $completeMiff -matte -deconstruct -layers optimizePlus $optimizedFile_3"
    * "convert $completeMiff -deconstruct -layers optimize -matte -colors 31 $optimizedFile_4"
    * "convert $completeMiff -deconstruct -layers optimize -matte \( -clone 0--1 -background none +append -quantize transparent -colors 64 -unique-colors -write mpr:cmap +delete \) -map mpr:cmap $optimizedFile_5"
    * "convert $completeMiff -deconstruct -layers optimize -matte \( -clone 0--1 -background none +append -quantize transparent -colors 32 -unique-colors -write mpr:cmap +delete \) -map mpr:cmap $optimizedFile_6"
PS:
Only two weeks experience with (pure) ImageMagick so far

Re: Reduce gif file size (tried optimize, optimizePlus, deconst)

Posted: 2009-03-16T08:58:24-07:00
by QooooQ
I just took a look at what identify tells me when checking the 728x90 banner.
While the ImageMagick frames have all about 65 kb (only some kb difference with color reducing), the Fireworks gif frames only have about 30 kb.
Do you know why ? Which commands could influence this size more dramatically ?

Re: Reduce gif file size (tried optimize, optimizePlus, deconst)

Posted: 2009-03-16T15:08:34-07:00
by fmw42
QooooQ wrote:I just took a look at what identify tells me when checking the 728x90 banner.
While the ImageMagick frames have all about 65 kb (only some kb difference with color reducing), the Fireworks gif frames only have about 30 kb.
Do you know why ? Which commands could influence this size more dramatically ?

If you are on Q16 (16-bit) IM, then you can add -depth 8 to get an 8-bit image rather than a 16-bit image.

Also you can use -colors to set the number of colors you want in your gif result.
see http://www.imagemagick.org/Usage/quantize/

Re: Reduce gif file size (tried optimize, optimizePlus, deconst)

Posted: 2009-03-16T16:40:45-07:00
by QooooQ
With...

Code: Select all

"convert $completeMiff -dither none -deconstruct -layers optimize -matte -depth 8 \( -clone 0--1 -background none +append -quantize transparent  -colors 32  -unique-colors -write mpr:cmap +delete \) -map mpr:cmap $optimizedFile_13"
...I can reduce the file size to 64 KB
And its looking good

But its still not enough.

Any suggestions ?!

Re: Reduce gif file size (tried optimize, optimizePlus, deconst)

Posted: 2009-03-16T17:04:47-07:00
by fmw42
QooooQ wrote:With...

Code: Select all

"convert $completeMiff -dither none -deconstruct -layers optimize -matte -depth 8 \( -clone 0--1 -background none +append -quantize transparent  -colors 32  -unique-colors -write mpr:cmap +delete \) -map mpr:cmap $optimizedFile_13"
...I can reduce the file size to 60 KB
And its looking good

But its still not enough.

Any suggestions ?!


To turn off dithering use +dither. I am not sure there is a -dither none option.

You can try setting -type Palette so that you get an 8-bit color mapped image rather than 8-bits per channel truecolor. See http://www.imagemagick.org/script/comma ... s.php#type

Re: Reduce gif file size (tried optimize, optimizePlus, deconst)

Posted: 2009-03-16T18:31:21-07:00
by QooooQ
fmw42 wrote: To turn off dithering use +dither. I am not sure there is a -dither none option.

You can try setting -type Palette so that you get an 8-bit color mapped image rather than 8-bits per channel truecolor. See http://www.imagemagick.org/script/comma ... s.php#type
-dither none comes from here http://www.imagemagick.org/Usage/quantize/#colors

tried the -type Palette setting, no difference. Or could you tell me where to insert it ? I have problems determining the right order of all these commands.

For example where to put it in here

Code: Select all

convert $completeMiff -dither none -deconstruct -layers optimize -matte -depth 8 \( -clone 0--1 -background none +append -quantize transparent  -colors 32  -unique-colors -write mpr:cmap +delete \) -map mpr:cmap $optimizedFile_13"

Re: Reduce gif file size (tried optimize, optimizePlus, deconst)

Posted: 2009-03-16T20:04:27-07:00
by fmw42
QooooQ wrote:
fmw42 wrote: To turn off dithering use +dither. I am not sure there is a -dither none option.

You can try setting -type Palette so that you get an 8-bit color mapped image rather than 8-bits per channel truecolor. See http://www.imagemagick.org/script/comma ... s.php#type
-dither none comes from here http://www.imagemagick.org/Usage/quantize/#colors

tried the -type Palette setting, no difference. Or could you tell me where to insert it ? I have problems determining the right order of all these commands.

For example where to put it in here

Code: Select all

convert $completeMiff -dither none -deconstruct -layers optimize -matte -depth 8 \( -clone 0--1 -background none +append -quantize transparent  -colors 32  -unique-colors -write mpr:cmap +delete \) -map mpr:cmap $optimizedFile_13"
You are right about -dither none. But interesting that it does not show up on http://www.imagemagick.org/script/comma ... php#dither as an option.

I would put -type palette right after -depth 8.

At this point I am at a loss the help further. Perhaps Anthony will be able to shed more light.

Re: Reduce gif file size (tried optimize, optimizePlus, deconst)

Posted: 2009-03-16T20:34:52-07:00
by QooooQ
hmm, thanks, but this didn't change the size.

Another thing
I just found those two lines in the verbose output of identify

Code: Select all

Filesize: 25.7kb
Number pixels: 20.4kb
in the gif produced by fireworks (frame 0)
and

Code: Select all

Filesize: 63kb
Number pixels: 64kb
in the imagemagick optimized gif (frame 0)

I understand that the filesize is related to the number of pixels. And now I see that there is less than 1/3 of the pixels in the fireworks file. Though both frames extracted and compared seem to be identical.
How can that be ? What am I missing ? How can I reduce the number of pixels ?

depth and number of colors are the same by the way

Re: Reduce gif file size (tried optimize, optimizePlus, deconst)

Posted: 2009-03-16T21:09:00-07:00
by fmw42
Filesize is not just the number of pixels. Check to be sure the dimension widthxheight in pixels in your IM vs Fireworks image are the same.

In IM,

identify imagename

will give you the dimensions, the bit-depth and the image type as well as the filesize. All these parameters contribute to the filesize.

You can also check the number of unique colors using -unique-colors. See http://www.imagemagick.org/Usage/quantize/#extract

Re: Reduce gif file size (tried optimize, optimizePlus, deconst)

Posted: 2009-03-17T06:14:28-07:00
by QooooQ
fmw42 wrote:Filesize is not just the number of pixels. Check to be sure the dimension widthxheight in pixels in your IM vs Fireworks image are the same.
Man I guess it was to late yesterday, you are right, it had different dimensions, both have 728x90 in frame 0, but i compared frame 0 with frame 1 accidently
So the correct values in frame 0 of the fireworks gif it are

Code: Select all

  Filesize: 25.7kb
  Number pixels: 64kb
fmw42 wrote: In IM,
identify imagename

Code: Select all

fw_opt.gif[0] GIF 728x90 728x90+0+0 8-bit PseudoClass 64c 25.7kb 
fw_opt.gif[1] GIF 348x60 728x90+0+13 8-bit PseudoClass 64c 25.7kb 
fw_opt.gif[2] GIF 441x64 728x90+123+9 8-bit PseudoClass 64c 25.7kb 
fw_opt.gif[3] GIF 389x60 728x90+339+13 8-bit PseudoClass 64c 25.7kb 
fw_opt.gif[4] GIF 170x60 728x90+558+13 8-bit PseudoClass 64c 25.7kb 
fw_opt.gif[5] GIF 663x64 728x90+32+5 8-bit PseudoClass 64c 25.7kb 
fw_opt.gif[6] GIF 728x37 728x90+0+53 8-bit PseudoClass 64c 25.7kb 
fw_opt.gif[7] GIF 728x57 728x90+0+33 8-bit PseudoClass 64c 25.7kb 
fw_opt.gif[8] GIF 728x90 728x90+0+0 8-bit PseudoClass 64c 25.7kb 
fw_opt.gif[9] GIF 76x54 728x90+484+0 8-bit PseudoClass 64c 25.7kb 
fw_opt.gif[10] GIF 85x87 728x90+478+0 8-bit PseudoClass 64c 25.7kb

Code: Select all

optimized_14_728x90.gif[0] GIF 728x90 728x90+0+0 8-bit PseudoClass 64c 63kb 
optimized_14_728x90.gif[1] GIF 348x60 728x90+0+13 8-bit PseudoClass 64c 63kb 
optimized_14_728x90.gif[2] GIF 441x64 728x90+123+9 8-bit PseudoClass 64c 63kb 
optimized_14_728x90.gif[3] GIF 389x60 728x90+339+13 8-bit PseudoClass 64c 63kb 
optimized_14_728x90.gif[4] GIF 170x60 728x90+558+13 8-bit PseudoClass 64c 63kb 
optimized_14_728x90.gif[5] GIF 663x64 728x90+32+5 8-bit PseudoClass 64c 63kb 
optimized_14_728x90.gif[6] GIF 728x37 728x90+0+53 8-bit PseudoClass 64c 63kb 
optimized_14_728x90.gif[7] GIF 728x57 728x90+0+33 8-bit PseudoClass 64c 63kb 
optimized_14_728x90.gif[8] GIF 728x90 728x90+0+0 8-bit PseudoClass 64c 63kb 
optimized_14_728x90.gif[9] GIF 77x54 728x90+484+0 8-bit PseudoClass 64c 63kb 
optimized_14_728x90.gif[10] GIF 85x87 728x90+478+0 8-bit PseudoClass 64c 63kb 
<--- Well, there you get this, and there I wondered about the 25,7 kb and the 63 kb. This is why I wanted to get more clues from
identify -verbose imagename

But I have no idea now, what else I should look for. Or is it something in the Channel statistics ?

Re: Reduce gif file size (tried optimize, optimizePlus, deconst)

Posted: 2009-03-17T06:24:58-07:00
by QooooQ
Was allowed to make files public.
This animated gif is produced by Fireworks. It has 28 KB and looks great
This animated miff is produced by ImageMagick. I can only reduce it to 64 KB, but this is to much. It needs to get near 30 KB.
Can someone help ?!

Re: Reduce gif file size (tried optimize, optimizePlus, deconst)

Posted: 2009-03-17T07:18:05-07:00
by QooooQ
Just downloaded a tool called gifsicle.
with

Code: Select all

gifsicle in.gif > out.gif
I get the 64 KB gif reduced to a 32 KB gif.

Can't find out what is happening when no parameter/option is given, but the fact that it reduces the gif to 32 KB, without any visible quality loss, is really cool.

I only wish I could reproduce this with ImageMagick commands and options now. So I could fine-tune this in the end.

Re: Reduce gif file size (tried optimize, optimizePlus, deconst)

Posted: 2009-03-17T10:29:49-07:00
by fmw42
QooooQ wrote:Was allowed to make files public.
This animated gif is produced by Fireworks. It has 28 KB and looks great
This animated miff is produced by ImageMagick. I can only reduce it to 64 KB, but this is to much. It needs to get near 30 KB.
Can someone help ?!

Did you mean MIFF or GIF? MIFF is an IM file format that will be much larger as it contains a lot of other information besides just the pixel data.

Re: Reduce gif file size (tried optimize, optimizePlus, deconst)

Posted: 2009-03-17T10:30:39-07:00
by fmw42
QooooQ wrote:Just downloaded a tool called gifsicle.
with

Code: Select all

gifsicle in.gif > out.gif
I get the 64 KB gif reduced to a 32 KB gif.

Can't find out what is happening when no parameter/option is given, but the fact that it reduces the gif to 32 KB, without any visible quality loss, is really cool.

I only wish I could reproduce this with ImageMagick commands and options now. So I could fine-tune this in the end.
My guess it is just the GIF optimization in IM is not as good as in Fireworks. But you need to hear from Anthony or Magick on this one.

Re: Reduce gif file size (tried optimize, optimizePlus, deconst)

Posted: 2009-03-17T15:09:58-07:00
by QooooQ
fmw42 wrote:
QooooQ wrote: Was allowed to make files public.
This animated gif is produced by Fireworks. It has 28 KB and looks great
This animated miff is produced by ImageMagick. I can only reduce it to 64 KB, but this is to much. It needs to get near 30 KB.
Can someone help ?!
Did you mean MIFF or GIF? MIFF is an IM file format that will be much larger as it contains a lot of other
information besides just the pixel data.
I posted a MIFF with the uncompressed, unoptimized and not reduced data.
And a gif (a gif opened and saved with Fireworks) to show whats possible and how the end product should look like and how big it should be.

When I say I can reduce the Miff to 64 KB, I mean that when I input the MIFF and run this (for example)

Code: Select all

"convert $completeMiff -dither none -matte -depth 8 -deconstruct  -layers optimizePlus -colors 32  $optimizedFile_16
I get a 64 KB GIF

I published the Miff so that you can try/experiment yourself.