php图片旋转显示不出来的,php – 我服务的图像不正确,它们都显示为旋转90度
在Exif中設(shè)置了方向.圖片沒有旋轉(zhuǎn)phisicaly.
圖像查看器可以使用它,但標(biāo)簽中的瀏覽器不會(huì)旋轉(zhuǎn)它.
你也可以“飛行”旋轉(zhuǎn)它.只需通過exif_read_data()獲取Exif信息,如果在’Orientation’中有3(180deg),6(90CW)或8(-90CCW),則旋轉(zhuǎn)它
// dump the picture and stop the script
$source = imagecreatefromjpeg($filename);
$exif = exif_read_data($filename);
if (isset($exif['Orientation'])) {
switch($exif['Orientation']) {
case 3: // 180 degree
$rotate=imagerotate($source,180,0);
break;
case 6: // 90 CW
$rotate=imagerotate($source,-90,0);
break;
case 8: // 90 CCW
$rotate=imagerotate($source,90,0);
break;
default:
$rotate=imagerotate($source,0,0);
break;
}
imagejpeg($rotate);
imagedestroy($source);
imagedestroy($rotate);
} else {
imagejpeg($source);
imagedestroy($source);
}
但當(dāng)然最好準(zhǔn)備一次所有圖片.
總結(jié)
以上是生活随笔為你收集整理的php图片旋转显示不出来的,php – 我服务的图像不正确,它们都显示为旋转90度的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 虚拟机随服务器启动,VMware Ser
- 下一篇: java 大数四则运算_大数四则运算ja