百度
360搜索
搜狗搜索

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

  下面是PHP 中 Orientation 属性判断上传图片是否需要旋转的代码:

<?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,判断不出是否被旋转了。

阅读更多 >>>  linux-image都可以删吗

网站数据信息

"PHP中Orientation属性判断上传图片是否需要旋转"浏览人数已经达到29次,如你需要查询该站的相关权重信息,可以点击进入"Chinaz数据" 查询。更多网站价值评估因素如:PHP中Orientation属性判断上传图片是否需要旋转的访问速度、搜索引擎收录以及索引量、用户体验等。 要评估一个站的价值,最主要还是需要根据您自身的需求,如网站IP、PV、跳出率等!