I'm trying to upload a base64 encoded image and save after decoding it. Image is getting uploaded and saved, and I can access it using a URL and everything..but the image gets rotated by 90 degrees anti-clockwise and I have no idea WHY!!
The place where I get the encoded data is fine, as putting it in <img />
works fine!
function saveImageData($base64Data) {
$base64_decoded = base64_decode($base64Data);
$im = imagecreatefromstring($base64_decoded);
if ($im !== false) {
$imagepath = '/public/uploads/' . time() . '.jpg';
imagejpeg($im, $imagepath);
chmod($imagepath, 0755);
imagedestroy($im);
} else {
return false;
}
return $imagepath;
}
I'm not using any rotation functions, but still its getting rotated. I can use a PHP GD function like imagerotate, but don't want to for reasons like black backgrounds etc.
If you can help..you r the awesomest person!!
See Question&Answers more detail:os