I am trying to rotate an image using php. I cannot seem to get the 'imagerotate' function to work. This is my code:
<?php
$degree = 45;
$img = imagecreatefromjpeg("mike.jpeg");
if($img == false){
echo 'imagecreatefromjpeg fail <br />';
}else{
echo 'imagecreatefromjpeg success <br />';
echo 'value $img: '.$img.'<br />'; //'Resource id #3' given.
}
$imgRotated = imagerotate($img, $degree, -1);// This is the problem!
if($imgRotated == false){
echo 'imgRotate fail <br />';
echo 'imgRotate value: '.$imgRotated.'<br />'; // '0' is returned every time
}else{
echo 'imgRotate success <br />';
}
imagejpeg($imgRotated, 'mikeRotated.jpeg', 100); // ERROR: 'imagejpeg() expects parameter 1 to be resource, boolean given'
?>
<img src="mike.jpeg"/>
<img src="mikeRotated.jpeg"/>
This is my gd_info():
GD Version / bundled (2.1.0 compatible) FreeType Support / 1 FreeType Linkage / with freetype T1Lib Support / 1 GIF Read Support / 1 GIF Create Support / 1 JPEG Support / 1 PNG Support / 1 WBMP Support / 1 XPM Support / 1 XBM Support / 1 JIS-mapped Japanese Font Support /

