【发布时间】:2017-02-15 13:07:42
【问题描述】:
我使用 Imagick 找到了解决方案 here 和 here,但由于安全问题,我真的不想使用 Imagick 扩展。
目前,我正在按如下方式调整大小:
list($width, $height) = getimagesize($file_path);
$src = imagecreatefrompng($file);
$dst = imagecreatetruecolor($newwidth, $newheight);
//prepare the transparency
imagealphablending($dst, false);
imagesavealpha( $dst , true );
$transparent = imagecolorallocatealpha($dst, 255, 255, 255, 127);
imagefilledrectangle($dst, 0, 0, $newwidth, $newheight, $transparent);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
但它始终设置为 72 DPI(甚至覆盖原始文件 DPI)。
有什么方法可以使用 GD 设置 DPI?
【问题讨论】: