Image rotation problem after uploading apple html

Source: Internet
Author: User

Recently made mobile Web project but encountered on the Apple device HTML upload pictures, the picture to the background is rotated rotation angle is different, so again

When reading photos, can not display properly, has now found a solution, as for the reasons for not quite understand the translation is also completely according to the word translation of different words.

But share the method. The reason is that Apple stole a lazy and did not deal with the photos after the shooting, while Android was processed.

The reason for the rotation is affected by the angle of the Apple device, and here's the workaround. PHP on the environment other languages to make the corresponding adjustment can be. Same principle

http://php.net/manual/en/function.exif-read-data.php

<?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 ']) {
Case8:
$image=Imagerotate($image,90,0);
Break
Case3:
$image=Imagerotate ( $image ,180 ,0             break;
        Case 6:
             $image  =  Imagerotate ( $image ,-90 ,0             break;
   }
}
//$image now contains a resource with the image oriented correctly
?>

Image rotation problem after uploading apple HTML

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.