Imagick usage for simple image attributes
Posted: 2012-06-11T11:38:40-07:00
Hi guys,
I'm trying to return the following image attributes:
Resolution (in dpi): xxx
Colorspace: xxx
Size (mm): xxx
At the moment I can get the resolution by doing the following:
... which is quite long winded, can I get this via Imagick? The documentation I find is very poor!
Also with the colorspace, I can get it to return an integer by the following:
... but it only returns 0 or 1 or whatever, I want to return a string like simply "RGB" or "CMYK", like it does if you do identify -verbose image.png
And lastly I can get the dimensions of the image with the following:
... but don't seem to be able to return it as millimeters or even centimeters as I can do the maths from there!
I've just installed Imagick after working with exec in PHP and am struggling to get my head around the functions at the moment. Any help at all on the above would be great!
Cheers.
I'm trying to return the following image attributes:
Resolution (in dpi): xxx
Colorspace: xxx
Size (mm): xxx
At the moment I can get the resolution by doing the following:
Code: Select all
<?php echo str_replace(' PixelsPerCentimeter','',round(exec("identify -format %x x %y -units PixelsPerInch $_uploadedFilePath"))) ?>
Also with the colorspace, I can get it to return an integer by the following:
Code: Select all
<?php echo $_image->getImageResolution() ?>
And lastly I can get the dimensions of the image with the following:
Code: Select all
<?php echo exec("identify -format %wx%h $_uploadedFilePath") ?>
I've just installed Imagick after working with exec in PHP and am struggling to get my head around the functions at the moment. Any help at all on the above would be great!
Cheers.