2

I build a simple function with getimagesize to find out if an image is horizontal or vertical.

// get height and width and then return
list($width, $height) = getimagesize('/path/to/imag.jpg');
if ($width > $height || $width == $height) {
    return 'HORIZONTAL';
} elseif ($height > $width) {
    return 'VERTICAL';
}

But this seems to fail on some images. Especially on a picture that is taken with a mobile device, holding it vertical. Photoshop opens it and shows it vertical, Mac Preview does too, but getimagesize keeps telling me width is bigger than height.

So I assume the information, this "horizontal" image should be shown "vertical" in Photo application is stored somewhere else.....

But where.... Exif?

spankmaster79
  • 21,555
  • 10
  • 42
  • 73
  • 1
    Reference: [Retrieve image orientation in PHP](http://stackoverflow.com/questions/13568440/retrieve-image-orientation-in-php), [How to stop PHP iMagick auto-rotating images based on EXIF 'orientation' data](http://stackoverflow.com/questions/4266656/how-to-stop-php-imagick-auto-rotating-images-based-on-exif-orientation-data). Can you provide an image that you're having trouble with? – Mike B Jan 25 '13 at 16:25

0 Answers0