处理图片出现翻转的问题
首先保证 php 开 exif 扩展
function rote($file){
$imagemodel = new Image();
$info = $imagemodel::GetImageInfo($file);
$type = empty($type) ? $info['type'] : $type;
$type = strtolower($type);
unset($info);
$image = imagecreatefromstring(file_get_contents($file));
//file_put_contents($log, $image.'\n');
$exif = @exif_read_data($file);
if(isset($exif['Orientation']) && !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;
}
}
$imageFun = 'image' . ($type == 'jpg' ? 'jpeg' : $type);
$imageFun($image,$file);
imagedestroy($image);
}