简体   繁体   English

PHP在服务器上显示来自PNG源的JPG图像?

[英]PHP displaying JPG image from PNG source on server?

我的服务器上是否可能有png图像,但是有一个php脚本将其转换为jpg(并压缩它们)并在查看时将其缓存?

You can use this script for convert PNG image into JPEG image. 您可以使用此脚本将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);

You can go through this @Alexandre Jasmin Answer . 您可以通过此@Alexandre Jasmin Answer进行操作

yes it is possible, you can google it using phrase " png convert to jpg php " 是的,有可能,您可以使用短语“ png convert to jpg php ”对其进行搜索

Use PHP to convert PNG to JPG with compression? 使用PHP通过压缩将PNG转换为JPG?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM