$image = new Imagick('image.jpg'); $orientation = $image->getImageOrientation(); echo $orientation;
$image = new Imagick('image.jpg'); $orientation = $image->getImageOrientation(); if ($orientation == Imagick::ORIENTATION_TOPLEFT) { $image->rotateImage('transparent', 90); }This example opens an image named 'image.jpg' using Imagick and then retrieves its orientation using the getImageOrientation() method. If the orientation is ORIENTATION_TOPLEFT, then the image is rotated by 90 degrees using the rotateImage() method. The package library used in these examples is the Imagick extension library for PHP.