Simple Image rotation with transparent background

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
Post Reply
Cadrach

Simple Image rotation with transparent background

Post by Cadrach »

Hi everyone,

I am trying to something quite simple really, rotation with a transparent background. I have tried a lot of things but I keep getting a black background after the rotation

Code: Select all

$img = new Imagick('file.png');
$img->setBackgroundColor(new ImagickPixel("transparent"));
$img->rotateImage(new ImagickPixel('transparent'), 45);
$img->save('fileRotate.png');
Before:
testImageS.png
testImageS.png (27.35 KiB) Viewed 6493 times
After:
testImageS.png
testImageS.png (21.29 KiB) Viewed 6493 times
If you have any idea, please let me know!
Cadrach

Re: Simple Image rotation with transparent background

Post by Cadrach »

After some more research, I found it:

Code: Select all

$img->distortImage(Imagick::DISTORTION_SCALEROTATETRANSLATE, array(45), true);
Post Reply