【发布时间】:2012-06-25 03:21:03
【问题描述】:
我已经查看了很多其他线程,有人遇到了 png 图像变黑的问题,它应该是透明的,但没有一个解决方案对我有用。
也许我在代码的其他地方出错了?也许我的网络服务器不支持 imagealhpableending?
感谢任何可以提供帮助的人。
$photo = imagecreatefrompng( "{$thumb_folder}{$new_file_name}" );
$width = imagesx($photo);
$height = imagesy($photo);
$new_width = 32;
$new_height = floor($height / ($width / $new_width));
$temp_photo = imagecreatetruecolor($new_width, $new_height);
imagealphablending($temp_photo, false);
imagesavealpha($temp_photo, true);
$transparent = imagecolorallocatealpha($temp_photo, 255, 255, 255, 127);
imagefilledrectangle($temp_photo, 0, 0, $new_width, $new_height, $transparent);
imagecopyresampled($temp_photo, $photo, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
imagepng($temp_photo, "{$thumb_folder}{$new_file_name}" );
【问题讨论】:
标签: php png transparent alpha