In PHP, the Orientation attribute determines whether the uploaded image needs to be rotated ,. In PHP, the Orientation attribute determines whether the image to be uploaded needs to be rotated. when using the iOS system to upload images, the image may be rotated, this mainly depends on the Orientation attribute in PHP to determine whether the uploaded image needs to be rotated,
When using the iOS system to upload images, you may encounter image rotation problems. this is mainly determined by the location of the photo button when you take the image. Assume that you rotate the mobile phone to the bottom up when taking the photo, and the photo is also rotated.
The following code ensures that all uploaded photos are correctly targeted when being uploaded:
<?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?>
After testing, the Orientation attribute of Android photos is 1, and it cannot be determined whether the image is rotated.
The Orientation attribute in http://www.bkjia.com/PHPjc/1062032.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/1062032.htmlTechArticlePHP determines whether to rotate the uploaded image. when using the iOS system of Apple to upload the image, the image may be rotated...