php识别翻转iphone拍摄的颠倒图片

2019-12-25  本文已影响0人  玛瑙鑫
public function save() {

$file = $_FILES['file'];

dump_log(原始凭证:', $file);

$exif = exif_read_data($file['tmp_name']);

//原图

$dst_image = imagecreatefromstring(file_get_contents($file['tmp_name']));

if (!empty($exif['Orientation'])) {

            switch ($exif['Orientation']) {

                case 8:

                    $dst_image = imagerotate($dst_image, 90, 0);

                    break;

                case 3:

                    $dst_image = imagerotate($dst_image, 180, 0);

                    break;

                case 6:

                    $dst_image = imagerotate($dst_image, -90, 0);

                    break;

            }

        }

//保存到本地

 imagejpeg($dst_image ,'../storage/tmp.jpeg');



 //释放内存

 imagedestroy($dst_image );

}
上一篇 下一篇

猜你喜欢

热点阅读