1

I want to rotate an image with transparent background fill to uncovered zone.

I refereed this official documentation with syntax

// Rotate
$rotate = imagerotate($source, $degrees, 0);

but did not get success.

After rotation I am getting image with black color fill to uncovered zone. like below

enter image description here

Original image is here

I also have tried below command

$> convert -rotate 5 image.png image_rotated.png

Reference is this

Above command I have used on png and jpg image, but I didn't get fruits..

Now I don't know where the things are going wrong ?? is there any problems with versions of library I am using ??

My php version is PHP 5.4.9-4ubuntu2.4

Thanks in advance.

Community
  • 1
  • 1
gkd
  • 853
  • 1
  • 14
  • 31

2 Answers2

1

Following command worked for me on Debian wheezy 7.5 with mageMagick 6.7.7-10.

convert -background "rgba(0,0,0,0)" -rotate 5 images.jpg new.png

Specify -background "rgba(0,0,0,0)" it will set transparent background fill for output image. Also make sure to save output image in .png format (which supports transparency)

Hope It will help. :)

Note: By default -rotate option uses Black color to fill background.

EDIT:

Make sure imagemagick package is installed properly.

check version details:

$convert --version
Version: ImageMagick 6.7.7-10 2014-03-08 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features: OpenMP 

If you are not getting similar output try checking for installation of package.

$sudo dpkg --get-selection | grep imagemagick

You might want to install that if its status is deinstalled in output of above command.

$sudo apt-get install imagemagick
Ravi Dhoriya ツ
  • 4,435
  • 8
  • 37
  • 48
0

since you are using php, I assume you will accept css code as answer? add these css to your image and it'll tilt

/* Firefox */
-moz-transform:rotate(45deg);
/* Safari and Chrome */
-webkit-transform:rotate(45deg);
/* Opera */
-o-transform:rotate(45deg);
/* IE9 */
-ms-transform:rotate(45deg);

edit: so not css huh, try this instead

$source = imagerotate($source,$degree,0XFFFFFF00,0); //<-- FFFFFF00 = RRGGBBAA
//you might not need to disable blending, try if it's not working
//imagealphablending($source, false);
imagesavealpha($source, true);
//then user $source however you want
Jacky Cheng
  • 1,536
  • 1
  • 10
  • 22
  • Thanks for taking interest in my problem, but I need to rotate an image and then overlay it on another big image at some angle. same way hundreds of images are there, and from those images one video file will be created that will be displayed on web. I don't require to show any image on browser. – gkd May 02 '14 at 11:09