【发布时间】:2016-07-17 01:21:03
【问题描述】:
我有一个处理图像处理的小类。
我使用以下来调整图像的大小
$this->image = imagecreatefrompng($filename);
....
$new_image = imagecreatetruecolor($width, $height);
imagecopyresampled($new_image, $this->image, 0, 0, 0, 0, $width, $height, $this->getWidth(), $this->getHeight());
...
$this->image = $new_image;
imagepng($this->image,$filename)) { return true; }
但是调整大小的图像没有保留透明度,而是黑色来了,我怎样才能保留透明度。
更新
之后,使用@Manuel 的代码,黑色部分减少了,但黑色背景仍然存在。源图像和结果图像是
Source & Sub 对应
main http://www.freeimagehosting.net/newuploads/820a0.pngsub http://www.freeimagehosting.net/newuploads/30526.png
【问题讨论】:
-
你应该检查this post
标签: php png transparency image-manipulation gd