I am having a problem rotating a PNG image and keeping the quality as high as it is when it wasn’t rotated. It is also losing its transparency.
Here is the code I’m using to rotate it:
$source = imagecreatefrompng('cake-test.png');
$col = imagecolorexact($source, 255, 255, 255);
imagecolortransparent($source, $col) ;
$rotate = imagerotate($source, 10, 0);
imagepng($rotate, 'temp.png') ;
The created image looks all aliased around the edges and has no transparency. Does anyone know how to get it to work or have a function they are willing to share?
Thanks! I had a background set on the div the image was in, now it looks fine.
You must allocate alpha channel with
imagecolorallocatealphaand setimagesavealphato true.Try this: