note 108526 deleted from imagick.getimageresolution by googleguy
| From: | googleguy@php.net | Date: | Tue, 22 Oct 2013 06:42:18 +0000 |
| Subject: | note 108526 deleted from imagick.getimageresolution by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-196603@lists.php.net to get a copy of this message | ||
Note Submitter: holdoffhunger at gmail dot com
----
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
)