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

PHP displaying JPG image from PNG source on server?

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

是的,你可以google它使用短语“png convert to jpg php

Use PHP to convert PNG to JPG with compression?

您可以使用此脚本将 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