【发布时间】:2021-01-21 03:21:51
【问题描述】:
我正在尝试通过从其他现有图像复制并使用 imagepng 功能来保存 PNG 图像,但保存的文件的大小增加了。 Here is the initial image.
$destWidth = 1920;
$destHeight = 1080;
$srcWidth = 1920;
$srcHeight = 1080;
// im.png : 399,1 ko
// width : 1920
// heigth : 1080
$image = imagecreatefrompng('im.png');
$imageDest = imagecreatetruecolor($destWidth, $destHeight);
imagecopyresampled($imageDest, $image, 0, 0, 0, 0, $destWidth, $destHeight, $srcWidth, $srcHeight);
// imnew.png : 857,5 ko
imagepng($imageDest, 'imnew.png');
初始图像有 399,1 ko(1920x1080)。 但结果图像有 857,5 ko(仍然是 1920x1080)。 为什么 ?有什么不增加尺寸的解决方案吗?
【问题讨论】:
-
真彩色图像比索引 PNG 占用更多空间。