3
votes

I'm converting .jpg and .gif images to .png using PHP's Imagick library.

I've successfully converted these images to .png using this:

$image = new Imagick( $file_path );
$image->setImageFormat( 'png' );
$image->writeImage( $file_path );

However, I have been unable to compress the .pngs or control their final size at all. I've tried using the following line before $image->setImageFormat() and a few other variations with no success:

$img->setImageCompressionQuality( 95 ); 

If .png compression with Imagick is lacking, then what other utilities should I use to compress these files?

This manual may help.

1
The manual entry you linked mentions pngcrush and OptiPng. Probably your best bet if you really need to bring file size down. - Frank Farmer

1 Answers

5
votes

I installed OptiPNG and it works fine.

After a lengthy battle, I was unable to get IMagick to compress png's properly.