Imagick rotate with PNG images

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
3sharpltd
Posts: 3
Joined: 2013-04-04T01:25:07-07:00
Authentication code: 6789

Imagick rotate with PNG images

Post by 3sharpltd »

I'm sure this is an old issue and i have seen this issue may times when googling this issue. However, i am using ImageMagick 6.8.4-6 with Imagick version 1620 on CentOS 6.4 and below is the code i am using to rotate my image however the background will not stay transparent. My Code:

Code: Select all

$imagick = new Imagick();
$imagick->readImage('images/Champs-43.png');
$imagick->rotateImage(new ImagickPixel(), 45); 



header('Content-Type: image/png');
echo $imagick->getImage();
instead of leaving ImagickPixel blank i have also tried "none", "transparent", "#00000000", and "rgba(0, 0, 0, 0.0)"

can anyone offer any suggestions?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Imagick rotate with PNG images

Post by fmw42 »

I am not an expert on Imagick. But
$imagick->rotateImage(new ImagickPixel(), 45);

see http://www.php.net/manual/en/imagick.rotateimage.php about setting the background color. Perhaps it should be

$imagick->rotateImage("transparent", 45);

Also it may be a bug in the version of IM. You may want to upgrade that and also upgrade Imagick. see http://pecl.php.net/package/imagick/3.1.0RC2
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Imagick rotate with PNG images

Post by Bonzo »

This works for me using Imagick API version 1608 ImageMagick 6.4.8 2010-10-13 Q16 :

Code: Select all

<?php  
$im = new Imagick($input); 
$im->rotateImage( new ImagickPixel('none'), 45 ); 
$im->writeImage('rotateImage.png');  
$im->destroy(); 
 ?> 
Post Reply