I am using imagerotate()
and imagecreatefromstring()
function to rotate the base64
image and update back to MySQL.
This is my code
$imageData = $rs[0]['image_data'];//image from DB
$im = imagecreatefromstring($imageData);
$degrees = $_REQUEST['selectrotate'];//Dynamic degrees.
ob_start();
$destImage = imagerotate($im, $degrees, 0) ;
imageJPEG($destImage);
$image_thumb =mysql_real_escape_string(ob_get_contents());
$imageDV=$image_thumb;
ob_end_clean();
Here what is happening:
$destImage = imagerotate($im, $degrees, 0);
In this line when I hard code $degrees
replacing some values, rotation is working fine.
But for dynamic degrees, rotation is taking +180. If dynamic value is 90 then image is rotated to 270 degrees.
Please help.