开发者

PHP: Image optimizator

开发者 https://www.devze.com 2023-01-27 13:20 出处:网络
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 Dir

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

精彩评论

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

关注公众号