开发者

What PHP compression utility and settings will mimic Photoshop's "Save for Web"?

I've tried about a half dozen compression utilities and have been unable to get anywhere near the compression level that Photoshop's "Save for Web" feature gets (5-10x smaller). I think the problem is that most of th开发者_JAVA技巧e utilities can't change bit depth of the image as part of the compression process.

I'd like to use a PHP compression utility (if possible).

My settings on Photoshop's "Save for Web" are:

png-8
selective
diffusion
no transparency
64 colors
100% dither


If it's a dramatic difference in size, then you are probably right and it's not reducing the bit-depth. ImageMagick is going to give you a good amount of control. The other thing that PS "save for web" does is strip most of the meta-data, but that savings is usually pretty minimal.

Using ImageMagick you can use the format png8:filename.png for 8-bit pngs, you'll have to look at the documentation to get the rest of the attribute settings, but note that for PNGs, the quality setting is not the same as lossy formats like jpg, each digit represents a different png setting.

To use, install the ImageMagick library and either run the commands via one of the PHP exec functions or install the PHP PECL extension, imagick.


Imagemagick is a nice PHP image utility and is used by most developers for advanced Image algorithms. I would recommend looking into this utility for further image manipulation needs. Specifically Imagick::setCompressionQuality

PHP Imagemagick


convert -thumbnail -quality '70%' from_path to_path

convert - console variant of ImageMagick... just play with settings...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜