我有一个非常奇怪的问题。
在我的网站上有一个文件字段,允许用户上传他们的个人资料图片。
使用JQuery
上传,然后使用PHP
保存。
如果我从PC / MAC / iPhone上传,那么没有任何问题,但是如果我使用Android
设备上传图像就会轮换。
旋转不均匀,可能是90%180%或270%,这是在拍摄图像或从图库中选择时发生的。
为什么会这样?并且有可能解决吗?
答案 0 :(得分:0)
这解决了问题
来自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
?>