php - 以透明颜色旋转图像

标签 php image-processing transparency image-rotation php-gd

我打算使用 php gd 旋转透明颜色的图像。但是旋转之后,图像中的透明色不再透明,背景也不透明了。这是我的代码。

$im = imagecreatefromgif('/images/80-2.gif');
$rotate = imagerotate($im,30,imagecolorallocatealpha($im, 0, 0, 0, 127));
imagegif($rotate,'/images/rotate.gif');
imagedestroy($im);
imagedestroy($rotate);

有人可以帮助我让它工作吗?谢谢。

最佳答案

为了保持图像的透明度,您需要使用两个设置,这两个设置可以通过在创建 gd 资源后立即调用这些函数来完成

imagealphablending( $im, false );
imagesavealpha( $im, true );

关于php - 以透明颜色旋转图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14633001/

相关文章:

Java GlassPanel 清晰透明背景

PHP 获取 PHP 文件

php - 当尝试传递包含在数据中的“符号”时,MySQL 语法出错

image - 为什么超声图像的 PSNR 会降低?

c - 我如何在互联网上找到 pbmpak.c 文件?

c - 使用缓冲区的 Windows AlphaBlend

c# - 设置用户控件的父级可防止其透明

javascript - 在 php 键中使用右方括号

php - 在动态时间范围后删除 SQL 中的特定行 - PHP、MYSQL

Azure 机器学习分类