How to convert PNG to 8-bit PNG using PHP GD library

前端 未结 2 1515
耶瑟儿~
耶瑟儿~ 2020-12-31 19:27

I want to write a routine which takes PNG image path as parameter and convert that image into 8-bit PNG image. I need to use PHP GD library for this.

2条回答
  •  鱼传尺愫
    2020-12-31 20:23

    Instead of GD library I strongly recommend using pngquant 1.5+ commandline using exec() or popen() functions.

    GD library has very poor-quality palette generation code.

    Same image as in the other answer, same file size as GD library, but converted using pngquant to merely 100 colors (not even 256):

    enter image description here

    pngquant supports alpha transparency very well.

提交回复
热议问题