PHP+Imagick - PNG Compression

后端 未结 2 1576
孤城傲影
孤城傲影 2020-12-19 06:39

How do I efficiently compress a PNG? In my case, the images are small grayscale images with transparency.

Currently I\'m playing with this:

// ...

$         


        
相关标签:
2条回答
  • 2020-12-19 07:11

    Have a look at the first part of this answer:

    • Convert multipage PDF to PNG and back (Linux)

    It explains the meaning + syntax of ImageMagick's -quality setting for PNGs.

    0 讨论(0)
  • 2020-12-19 07:12

    I'm definitely not sure if it is correct way to save PNG, but my way is:

    $im->setImageCompression(\Imagick::COMPRESSION_UNDEFINED);
    $im->setImageCompressionQuality(0);
    

    This gives me perfect quality of the image and file size very similar to PS6 saved 'Save for Web'. Sometimes even smaller sizes!

    0 讨论(0)
提交回复
热议问题