I need suggestion on which is the best available module/method to compress PNG file with transparent/alpha support.

I tried with ImageMagick, it works great on JPG but when deal with PNG, I can't make the file size smaller. Tried all kinds of method.

I also tried with using PHP imagecreatefrompng, imagepng but it screw up the transparent on output.

The only best I tested is using pngquant (command line). But it is only on my Windows IIS ActivePerl environment. I'm not sure how to install/setup pngquant on my linux hosting server. It is too complicated to me.

So I seek for alternative method in perl which I'm more familiar with.

Any help are very much appreciated. Thanks.

* UPDATE *
ImageMagick using $image->Resize(geometry => "${width}x${height}"); able to resize the PNG (with transparent). Without transparent resize also ok but file size still not small compare to pngquant.

I still need a PNG compression without resizing dimension.

* UPDATE *
This only able to reduce png file size from 1,666kb to 1,228kb without resize dimension.

$image->Set(quality =>'95'); $image->Set(depth=>'8');

* UPDATE *
After done more test with imagemagick, the best it only able to reduce about 20%. My current final best test still on pngquant where from 1666kb to 377kb. That is Huge difference.

pngquant command used pngquant --quality 20-40 -speed 11 [png file]

* FINAL UPDATE *
I have decided to use pngquant and managed to get it installed on linux.


In reply to PNG compression support transparent by hankcoder

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.