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

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?".

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

Postby QooooQ » 2009-03-16T07:34:05+00:00

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
Last edited by QooooQ on 2009-03-17T16:10:18+00:00, edited 10 times in total.
QooooQ
 

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

Postby QooooQ » 2009-03-16T08:58:24+00:00

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 ?
QooooQ
 

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

Postby fmw42 » 2009-03-16T15:08:34+00:00

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/
User avatar
fmw42
 
Posts: 14880
Joined: 2007-07-02T17:14:51+00:00
Location: Sunnyvale, California, USA

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

Postby QooooQ » 2009-03-16T16:40:45+00:00

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 ?!
Last edited by QooooQ on 2009-03-16T19:48:31+00:00, edited 1 time in total.
QooooQ
 

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

Postby fmw42 » 2009-03-16T17:04:47+00:00

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
User avatar
fmw42
 
Posts: 14880
Joined: 2007-07-02T17:14:51+00:00
Location: Sunnyvale, California, USA

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

Postby QooooQ » 2009-03-16T18:31:21+00:00

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"
QooooQ
 

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

Postby fmw42 » 2009-03-16T20:04:27+00:00

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.
User avatar
fmw42
 
Posts: 14880
Joined: 2007-07-02T17:14:51+00:00
Location: Sunnyvale, California, USA

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

Postby QooooQ » 2009-03-16T20:34:52+00:00

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
QooooQ
 

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

Postby fmw42 » 2009-03-16T21:09:00+00:00

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
User avatar
fmw42
 
Posts: 14880
Joined: 2007-07-02T17:14:51+00:00
Location: Sunnyvale, California, USA

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

Postby QooooQ » 2009-03-17T06:14:28+00:00

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 ?
QooooQ
 

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

Postby QooooQ » 2009-03-17T06:24:58+00:00

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 ?!
QooooQ
 

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

Postby QooooQ » 2009-03-17T07:18:05+00:00

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.
QooooQ
 

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

Postby fmw42 » 2009-03-17T10:29:49+00:00

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.
User avatar
fmw42
 
Posts: 14880
Joined: 2007-07-02T17:14:51+00:00
Location: Sunnyvale, California, USA

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

Postby fmw42 » 2009-03-17T10:30:39+00:00

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.
User avatar
fmw42
 
Posts: 14880
Joined: 2007-07-02T17:14:51+00:00
Location: Sunnyvale, California, USA

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

Postby QooooQ » 2009-03-17T15:09:58+00:00

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.
QooooQ
 

Next

Return to Users

Who is online

Users browsing this forum: Baidu [Spider], Bing [Bot], Google Adsense [Bot] and 22 guests