When you use an Apple iOS system to photograph and upload images, you may experience a problem with the image being rotated, depending on the position of the camera button when you take the picture. Let's say you rotate your phone around the bottom while you're taking a picture, and the picture is rotated.
The following code will ensure that all uploaded photos are correctly directed as they are 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, Android photographed the Orientation property is 1, can not determine whether it was rotated.