我的服务器上是否可能有png图像,但有一个php脚本将其转换为jpg(并压缩它们)并在查看时将其缓存?
您可以使用此脚本将PNG图像转换为JPEG图像。
$input_file = "test.png";
$output_file = "test.jpg";
$input = imagecreatefrompng($input_file);
list($width, $height) = getimagesize($input_file);
$output = imagecreatetruecolor($width, $height);
imagecopy($output, $input, 0, 0, 0, 0, $width, $height);
imagejpeg($output, $output_file);
您可以通过此@Alexandre Jasmin Answer进行操作。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句