Home >Backend Development >PHP Tutorial >PHP 中 Orientation 属性判断上传图片是否需要旋转

PHP 中 Orientation 属性判断上传图片是否需要旋转

WBOY
WBOYOriginal
2016-06-23 13:19:44798browse

<?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?>

经测试,Android拍照的 Orientation 属性都是1,判断不出是否被旋转了。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn