Link to home
Start Free TrialLog in
Avatar of tonelm54
tonelm54

asked on

GD Rotate not working

Im trying to simply rotate some text by 15 degrees, but I cant get it working at all despite multiple debug lines

My simplified code I dont think I could get more simpler, what Ive done is:-

<?php
header('Content-Type: image/png');

$im = imagecreatetruecolor(300, 150);
$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);

imagefilledrectangle($im, 0, 0, 300, 150, $white);

$text = 'Testing...';
$font = 'arial.ttf';

imagettftext($im, 20, 0, 10, 20, $black, $font, $text);

imagerotate($im, 15, 0);

imagepng($im);
imagedestroy($im);
?>

Open in new window


Any idea what Im doing wrong?
ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
No points for this, please, but when in doubt it's always wise to check the online man pages.  I could not work without a window open to PHP.net at all times.  In the instant case you can see that the imagerotate() function returns a resource.
http://php.net/manual/en/function.imagerotate.php

I can see how this can be confusing, since many of the other image functions mutate a resource and return something like a boolean, but that is the unfortunate nature of PHP - it's hard to guess what will be changed or returned without reference to the manual.  Example of a related function:
http://php.net/manual/en/function.imagesetinterpolation.php
Hi,

Try installing "imagick" and restarted apache.