Retrieve image orientation in PHP

后端 未结 6 972
闹比i
闹比i 2021-02-04 06:54

How can I get the image orientation (landscape or portrait) of an image (JPEG or PNG) in PHP?

I created a php site where users can upload pictures. Before I scale them

6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-04 07:17

    list($width, $height) = getimagesize("path/to/your/image.jpg");
    
    if( $width > $height)
        $orientation = "landscape";
    else
        $orientation = "portrait";
    

提交回复
热议问题