如何在GD上旋转时保持png的透明度。 120度?

时间:2015-02-19 19:01:23

标签: php rotation png transparency gd

这是我正在尝试旋转的图像

http://www.flaticon.com/free-icon/arrow-point-to-right_32213

如果旋转Nx90度,这个代码可以提供完美的透明度,但是只要我将其旋转到例如170或120度我得到一个黑框......我怎样才能得到所有透明的背景?

$filename = 'arrow487.png';

$degrees = 170;

 $png = imagecreatefrompng($filename);
$transparency = imagecolorallocatealpha( $png,0,0,0,127 );


$rotated = imagerotate( $png, $degrees, $transparency, 1);

imagealphablending( $rotated, false );

imagesavealpha( $rotated, true );

ob_end_clean();

header( 'Content-Type: image/png' );
imagepng( $rotated );

0 个答案:

没有答案