note 111448 added to imagick.getimageorientation

From: Date: Wed, 20 Feb 2013 21:23:58 +0000
Subject: note 111448 added to imagick.getimageorientation
Groups: php.notes 
Request: Send a blank email to php-notes+get-193705@lists.php.net to get a copy of this message
Here's how you can use the getImageOrientation() information to auto-rotate images to their correct orientation... // Note: $image is an Imagick object, not a filename! See example use below. function autoRotateImage($image) { $orientation = $image->getImageOrientation(); switch($orientation) { case imagick::ORIENTATION_BOTTOMRIGHT: $image->rotateimage("#000", 180); // rotate 180 degrees break; case imagick::ORIENTATION_RIGHTTOP: $image->rotateimage("#000", 90); // rotate 90 degrees CW break; case imagick::ORIENTATION_LEFTBOTTOM: $image->rotateimage("#000", -90); // rotate 90 degrees CCW break; } // Now that it's auto-rotated, make sure the EXIF data is correct in case the EXIF gets saved with the image! $image->setImageOrientation(imagick::ORIENTATION_TOPLEFT); } Example use: $image = new Imagick('my-image-file.jpg'); autoRotateImage($image); // - Do other stuff to the image here - $image->writeImage('result-image.jpg'); ---- Server IP: 69.147.83.199 Probable Submitter: 99.88.245.232 ---- Manual Page -- http://php.net/manual/en/imagick.getimageorientation.php Edit -- https://master.php.net/note/edit/111448 Del: integrated -- https://master.php.net/note/delete/111448/integrated Del: useless -- https://master.php.net/note/delete/111448/useless Del: bad code -- https://master.php.net/note/delete/111448/bad+code Del: spam -- https://master.php.net/note/delete/111448/spam Del: non-english -- https://master.php.net/note/delete/111448/non-english Del: in docs -- https://master.php.net/note/delete/111448/in+docs Del: other reasons-- https://master.php.net/note/delete/111448 Reject -- https://master.php.net/note/reject/111448 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#193705) next »