Imagick provides various ways to identify image properties. These properties include for example some basic attributes like width, height, format and some more advanced attributes like exif tags, profiles and colorspaces.
This example will demonstrate a few basic ways to read these attributes from an image. The image used in this example is from www.exif.org and can be found here http://exif.org/samples/fujifilm-dx10.jpg.
The support for getImageProperties and getImageProfiles was added in ImageMagick version 6.3.5-9 and Imagick version 2.0.0RC4.
-
<?php
-
-
$im = new Imagick( "fujifilm-dx10.jpg" );
-
$identify = $im->identifyImage();
-
-
/* Ouput some basic attributes */
-
echo '<b>Basic image properties:</b> <br />';
-
echo 'Image geometry: ' , $identify['geometry']['width'] , 'x' , $identify['geometry']['height'] , '<br />';
-
-
echo '<br /><br />';
-
-
echo '<b>All image properties:</b> <br />';
-
-
/* Loop trough image properties */
-
foreach ( $im->getImageProperties() as $k => $v )
-
{
-
}
-
-
echo '<br /><br />';
-
-
echo '<b>All image profiles:</b> <br />';
-
/* Same goes for properties */
-
foreach ( $im->getImageProfiles() as $k => $v )
-
{
-
}
-
-
?>
The output looks something like this:
Basic image properties:
Image geometry: 1024x768
Image format: JPEG (Joint Photographic Experts Group JFIF format)
Image type: TrueColor
Image compression: JPEG
Image size: 129.955kb
All image properties:
exif:ApertureValue => 41/10
exif:BrightnessValue => -27/10
exif:ColorSpace => 1
exif:ComponentsConfiguration => ...
exif:CompressedBitsPerPixel => 14/10
exif:Compression => 6
exif:Copyright => J P Bowen
exif:DateTime => 2001:04:12 20:33:14
exif:DateTimeDigitized => 2001:04:12 20:33:14
exif:DateTimeOriginal => 2001:04:12 20:33:14
exif:ExifImageLength => 768
exif:ExifImageWidth => 1024
exif:ExifOffset => 258
exif:ExifVersion => 0210
exif:ExposureBiasValue => 0/10
exif:ExposureProgram => 2
exif:FileSource => .
exif:Flash => 1
exif:FlashPixVersion => 0100
exif:FNumber => 42/10
exif:FocalLength => 58/10
exif:FocalPlaneResolutionUnit => 3
exif:FocalPlaneXResolution => 2151/1
exif:FocalPlaneYResolution => 2151/1
exif:InteroperabilityIndex => R98
exif:InteroperabilityOffset => 708
exif:InteroperabilityVersion => 0100
exif:ISOSpeedRatings => 150
exif:JPEGInterchangeFormat => 856
exif:JPEGInterchangeFormatLength => 10274
exif:Make => FUJIFILM
exif:MaxApertureValue => 41/10
exif:MeteringMode => 5
exif:Model => DX-10
exif:Orientation => 1
exif:ResolutionUnit => 2
exif:SceneType => .
exif:SensingMethod => 2
exif:ShutterSpeedValue => 66/10
exif:Software => Digital Camera DX-10 Ver1.00
exif:XResolution => 72/1
exif:YCbCrPositioning => 2
exif:YResolution => 72/1
jpeg:colorspace => 2
jpeg:sampling-factor => 2x1,1x1,1x1
Signature => 434d8554488bf9af5fc551adeba43e6d1d04ac36559a02357cf5df93db4b35c5
All image profiles:
Profile name: exif (size: 11136)











