Using the getImageOrientation function, you'll get the Orientation value for an image as defined within the EXIF file format. That means you will get back an integer representation one of the Orientation constants for ImageMagick, which looks like " imagick::ORIENTATION_UNDEFINED", with "_VALUE" values of: undefined (0), topleft (1), topright (2), bottomright (3), bottomleft (4), lefttop (5), righttop (6), rightbottom (7), and leftbottom (8). When printed out directly, these predefined constants produce the number in parenthesis. The undefined being set to 0 makes sense, since -- according to Wikipedia -- EXIF allows for eight possible values for an image (and not every image has a set of EXIF properties).
The EXIF Orientation is also called "the Rotation," again, according to Wikipedia: http://www.imagemagick.org/Usage/photos/ )
If you're having trouble getting this function to show the value for Image Orientation, then use the function and parameters of getImageProperties('*', FALSE); . This produces an array of all properties associated with an image, and one of them will have the key value of exif:Orientation. If it doesn't, then that means you will be getting back a zero from this function, indicating an "Undefined" orientation.
Some sample code :
<?php
$imagick_type = new Imagick();
$file_to_grab = "image_workshop_directory/test.jpg";
$file_handle_for_viewing_image_file = fopen($file_to_grab, 'a+');
$imagick_type->readImageFile($file_handle_for_viewing_image_file);
$imagick_orientation = $imagick_type->getImageOrientation();
switch($imagick_orientation)
{
case '0':
$imagick_orientation_evaluated = "Undefined";
break;
case '1':
$imagick_orientation_evaluated = "Top-Left";
break;
case '2':
$imagick_orientation_evaluated = "Top-Right";
break;
case '3':
$imagick_orientation_evaluated = "Bottom-Right";
break;
case '4':
$imagick_orientation_evaluated = "Bottom-Left";
break;
case '5':
$imagick_orientation_evaluated = "Left-Top";
break;
case '6':
$imagick_orientation_evaluated = "Right-Top";
break;
case '7':
$imagick_orientation_evaluated = "Right-Bottom";
break;
case '8':
$imagick_orientation_evaluated = "Left-Bottom";
break;
}
print("# $imagick_orientation - $imagick_orientation_evaluated");
?>