thinkphp image类 缩略图为什么旋转九十度
展开全部
我这样解决的:
$src = $_FILES['imgfile']['tmp_name'];
if($src){
$image = imagecreatefromstring(file_get_contents($src));
$exif = exif_read_data($src);
if(!empty($exif['Orientation'])) {
switch($exif['Orientation']) {
case 8:
$rotate = imagerotate($image,90,0);
break;
case 3:
$rotate = imagerotate($image,180,0);
break;
case 6:
$rotate = imagerotate($image,-90,0);
break;
}
imagepng($rotate,$src,100);
}
$image = \think\Image::open($src);
$image->thumb(300,200);
$saveName = time() . '.png';
$image->save(ROOT_PATH . 'public/static/uploads/' . $saveName);
$data["img"] = '/uploads/' . $saveName;
}
直接旋转了临时文件,反正压缩后都是png,就不分图片类型了。
$src = $_FILES['imgfile']['tmp_name'];
if($src){
$image = imagecreatefromstring(file_get_contents($src));
$exif = exif_read_data($src);
if(!empty($exif['Orientation'])) {
switch($exif['Orientation']) {
case 8:
$rotate = imagerotate($image,90,0);
break;
case 3:
$rotate = imagerotate($image,180,0);
break;
case 6:
$rotate = imagerotate($image,-90,0);
break;
}
imagepng($rotate,$src,100);
}
$image = \think\Image::open($src);
$image->thumb(300,200);
$saveName = time() . '.png';
$image->save(ROOT_PATH . 'public/static/uploads/' . $saveName);
$data["img"] = '/uploads/' . $saveName;
}
直接旋转了临时文件,反正压缩后都是png,就不分图片类型了。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询