470,815 Members | 1,364 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,815 developers. It's quick & easy.

Problem with "imagerotate"

Does the "imagerotate" function in PHP5 work correctly or am I doing
something wrong?

I'm using the code shown below to generate a simple rectangle and then
to rotate it a specific number of degrees. The actual rotation itself
seems to happen OK but the background color appears correctly only if
the rotation is between 1 and 45 degrees; any other value and the
background is black. And, in neither case does the
"imagecolortransparent" work (I want the background to be
transparent).
$myImg = imagecreate($somelength,$somewidth);
$myBG = imagecolorallocate($myImg,85,255,255);
$RectColor = imagecolorallocate($myImg,200,200,200);
$myBlack = imagecolorallocate($myImg, 0, 0, 0);
imagefilledrectangle($myImg,1,1,($somelength-2),($somewidth-2),
$RectColor);
imagerectangle($myImg,0,0,($somelength-1),($somewidth-1), $myBlack);

$myImage = imagerotate($myImg, $someangle, $myBG);

imagedestroy($myImg);

imagecolortransparent($myImage,$myBG);

imagepng($myImage,"gMyRect.png");
imagedestroy($myImage);

Jul 17 '05 #1
0 1690

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.