开发者

PHP: Image optimizator

How would one go on about building a script that would optimize an entire folder of images (jpg's) for maximum file size reduction (at 开发者_高级运维a reasonable loss of quality)?


You could use a DirectoryIterator and a couple of GD functions: imagecreatefromjpeg() and imagejpeg() to do this, but you don't get much control over the output as you can only specify a percentage quality for the JPEG.

The only way to get a "reasonable loss of quality" is to review each one by hand, I'm afraid.


PHP includes a graphics library that can load and save images as well as manipulate them while in memory. The docs are here.

Functions like scandir() will help you get a list of files in a folder, though there are lots of file functions that will help.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜