Imagick::identifyImage
(PECL imagick 2.0.0)
Identifies an image and fetches attributes
说明
Imagick::identifyImage ([bool $appendRawOutput= FALSE
] ) : array
Identifies an image and returns the attributes. Attributes include the image width, height, size, and others.
参数
- $appendRawOutput
If
TRUE
then the raw output is appended to the array.
返回值
Identifies an image and returns the attributes. Attributes include the image width, height, size, and others.
Example #1 Example Result Format
Array ( [imageName] => /some/path/image.jpg [format] => JPEG (Joint Photographic Experts Group JFIF format) [geometry] => Array ( [width] => 90 [height] => 90 ) [type] => TrueColor [colorSpace] => RGB [resolution] => Array ( [x] => 300 [y] => 300 ) [units] => PixelsPerInch [fileSize] => 1.88672kb [compression] => JPEG [signature] => 9a6dc8f604f97d0d691c0286176ddf992e188f0bebba98494b2146ee2d7118da )
错误/异常
错误时抛出 ImagickException。
If you use the option to append the raw output, you can extract the mime type from there. I'm not sure what's going on in the background here, but it seems far less useful than the command line identify tool.
The array returned by Imagick::identifyImage(): Array ( [imageName] => /some/path/image.jpg [format] => JPEG (Joint Photographic Experts Group JFIF format) [geometry] => Array ( [width] => 90 [height] => 90 ) [type] => TrueColor [colorSpace] => RGB [resolution] => Array ( [x] => 300 [y] => 300 ) [units] => PixelsPerInch [fileSize] => 1.88672kb [compression] => JPEG [signature] => 9a6dc8f604f97d0d691c0286176ddf992e188f0bebba98494b2146ee2d7118da ) Looks like the only way to get the mimetype is getimagesize()...