【发布时间】:2019-06-23 19:57:14
【问题描述】:
我让 exif 读取上传图像的方向。 问题是在一些图像中我收到了这个错误:
警告 exif_read_data(php3KLADx): 文件不支持 /home/i/public_html/orientation.php 在第 5 行
任何想法如何避免这种情况?
<?php
function exif_orientation($file_tmp) {
$image = imagecreatefromstring(file_get_contents($file_tmp));
$exif = exif_read_data($file_tmp);
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;
}
imagejpeg($image, $file_tmp, 90);
}
}
?>
【问题讨论】:
标签: php