nim*_*rod 13 php image orientation
如何在PHP中获取图像(JPEG或PNG)的图像方向(横向或纵向)?
我创建了一个用户可以上传图片的php网站.在我将它们缩小到更小的尺寸之前,我想知道图像是如何定向的,以便正确地缩放它.
感谢您的回答!
小智 38
我一直这样做:
list($width, $height) = getimagesize('image.jpg');
if ($width > $height) {
// Landscape
} else {
// Portrait or Square
}
Run Code Online (Sandbox Code Playgroud)
list($width, $height) = getimagesize("path/to/your/image.jpg");
if( $width > $height)
$orientation = "landscape";
else
$orientation = "portrait";
Run Code Online (Sandbox Code Playgroud)