views:

519

answers:

2

Hi fellow programmers,

I'm wondering how to compress an PNG image correctly.

The situation is this :

I have a PNG image compressed and color-reduced with Irfanview on Windows. It's about 20KB. When my portal software resizes (using magickwand 1.0.7) it with default values, it's about 63K (!).

Next try was to call MagickSetImageDepth($this->_imageHandler,8), resulting in a filesize of 34K, which is better, but still it's bigger than the (larger in dimension) original file.

None of the documented functions seem to fit to further compress the image.

Any hint would be greatly appreciated !

Greetz, Sosa

A: 

Try this tool by Yahoo - it's great!

http://developer.yahoo.com/yslow/smushit/

Chris Harris
+1  A: 

PNG compression programs and routines use different techniques. I've found out that many times, an image that's already been compressed (or saved efficiently) cannot be compressed further or even has a higher file size as you are experiencing.

In your case I'd say your images cannot be compressed further, at least using MagickWand. You might just want to leave out that step.

Perhaps optimizing your PNGs before runtime would be a solution. There are many options available in this case. I've had luck with PNGGauntlet. You can run a batch job on PNGGauntlet and it will skip over the files that it would've made larger, if any.

T Pops