Images Rotating
I have a very strange problem.
On my website there is a file field that will allow the users to upload their profile picture.
It gets uploaded using JQuery
and it gets saved using PHP
.
If I upload from a PC / MAC / iPhone then there is no problem whatsoever, however if I upload using an Android
device the image gets rotated.
The rotation is not even consistent, it could be 90% 180% or 270%, this happens when taking a image or selecting from the Gallery.
Why would this happen? and is there a possible fix?
This solved the issue
From the PHPDocs
<?php
$image = imagecreatefromstring(file_get_contents($_FILES['image_upload']['tmp_name']));
$exif = exif_read_data($_FILES['image_upload']['tmp_name']);
if(!empty($exif['Orientation'])) {
switch($exif['Orientation']) {
case 8:
$image = imagerotate($image,90,0);
break;
case 3:
$image = imagerotate($image,180,0);
break;
case 6:
$image = imagerotate($image,-90,0);
break;
}
}
// $image now contains a resource with the image oriented correctly
?>
链接地址: http://www.djcxy.com/p/61156.html
上一篇: 使用Facebook进行身份验证的网站的REST API
下一篇: 图像旋转