note 108526 added to imagick.getimageresolution

From: Date: Thu, 03 May 2012 23:39:04 +0000
Subject: note 108526 added to imagick.getimageresolution
Groups: php.notes 
Request: Send a blank email to php-notes+get-187462@lists.php.net to get a copy of this message
If you're doing anything intensive with the ImageMagick class, then you're going to be working with the resolution of the image a lot. In my install of PHP v.5.2.17, this function returns incorrect values, but a replacement function is easy to write by using a combination of the getImageHeight and getImageWidth properties, like so : <?php // Grab Image File Data // --------------------------------------------- $file_to_grab_with_location = "image_workshop_directory/test.bmp"; $imagick_type = new Imagick(); // Open File // --------------------------------------------- $file_handle_for_viewing_image_file = fopen($file_to_grab_with_location, 'a+'); $imagick_type->readImageFile($file_handle_for_viewing_image_file); // Create Resolution Array // --------------------------------------------- $imagick_type_resolution = array(); // Give Resolution Array Proper Values // --------------------------------------------- $imagick_type_resolution['x'] = $imagick_type->getImageWidth(); $imagick_type_resolution['y'] = $imagick_type->getImageHeight(); // Output // --------------------------------------------- print_r($imagick_type_resolution); ?> Results of the Output: Array ( [x] => 600 [y] => 450 ) ---- Server IP: 69.147.83.197 Probable Submitter: 68.9.137.178 ---- Manual Page -- http://www.php.net/manual/en/imagick.getimageresolution.php Edit -- https://master.php.net/note/edit/108526 Del: integrated -- https://master.php.net/note/delete/108526/integrated Del: useless -- https://master.php.net/note/delete/108526/useless Del: bad code -- https://master.php.net/note/delete/108526/bad+code Del: spam -- https://master.php.net/note/delete/108526/spam Del: non-english -- https://master.php.net/note/delete/108526/non-english Del: in docs -- https://master.php.net/note/delete/108526/in+docs Del: other reasons-- https://master.php.net/note/delete/108526 Reject -- https://master.php.net/note/reject/108526 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#187462) next »