Page 1 of 1

Imagick rotate with PNG images

Posted: 2013-09-16T06:59:27-07:00
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?

Re: Imagick rotate with PNG images

Posted: 2013-09-16T10:09:05-07:00
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

Re: Imagick rotate with PNG images

Posted: 2013-09-17T05:02:10-07:00
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(); 
 ?>