Sunday, May 17, 2026
HomeLanguagesPHP | Imagick identifyImage() Function

PHP | Imagick identifyImage() Function

The Imagick::identifyImage() function is an inbuilt function in PHP which is used to identify an image and return its attributes. Attributes contain image width, height, size, and others. 
Syntax: 
 

array Imagick::identifyImage( $appendRawOutput )

Parameters: This function accepts single parameter $appendRawOutput which is used to stores the value TRUE/FALSE. If it set to TRUE then the raw output is appended to the array.
Return Value: This function returns the image attributes.
Original Image: 
 

Below program illustrates the Imagick::identifyImage() function in PHP:
Program 1: 
 

php




<?php
 
// require_once('path/vendor/autoload.php');
 
// Create an Imagick Object
$imagick = new \Imagick(
     
// Use identifyImage Function
var_dump ($imagick->identifyImage());
?>


Output: 
 

array(11) { 
    ["imageName"]=> string(0) "" 
    ["mimetype"]=> string(9) "image/png" 
    ["format"]=> string(31) "PNG (Portable Network Graphics)" 
    ["units"]=> string(19) "PixelsPerCentimeter" 
    ["type"]=> string(14) "TrueColorAlpha" 
    ["colorSpace"]=> string(4) "sRGB" 
    ["compression"]=> string(3) "Zip" 
    ["fileSize"]=> string(6) "45.4KB" 
    ["geometry"]=> array(2) { ["width"]=> int(667) ["height"]=> int(184) } 
    ["resolution"]=> array(2) { ["x"]=> float(37.8) ["y"]=> float(37.8) } 
    ["signature"]=> string(64) "f64054f5bcb4cfb82c6126eff6d3d4e6be7d0e72d5620033442cecb4b9feabbd" 
}

Program 2: 
 

php




<?php
 
$string = "Computer Science portal for Geeks!";
 
// Creating new image of above String
// and add color and background
$im = new Imagick();
$draw = new ImagickDraw();
 
// Fill the color in image
$draw->setFillColor(new ImagickPixel('green'));
 
// Set the text font size
$draw->setFontSize(50);
 
$matrix = $im->queryFontMetrics($draw, $string);
$draw->annotation(0, 40, $string);
$im->newImage($matrix['textWidth'], $matrix['textHeight'],
new ImagickPixel('white'));
 
// Draw the image        
$im->drawImage($draw);
 
// identifyImage Function
var_dump ($im->identifyImage());
?>


Output: 
 

array(10) { 
    ["imageName"]=> string(0) "" 
    ["mimetype"]=> string(8) "image/x-" 
    ["units"]=> string(9) "Undefined" 
    ["type"]=> string(12) "PaletteAlpha" 
    ["colorSpace"]=> string(4) "sRGB" 
    ["compression"]=> string(9) "Undefined" 
    ["fileSize"]=> string(2) "0B" 
    ["geometry"]=> array(2) { ["width"]=> int(797) ["height"]=> int(62) } 
    ["resolution"]=> array(2) { ["x"]=> float(0) ["y"]=> float(0) } 
    ["signature"]=> string(64) "7c71a28f88b25287580277af67861eaa6f02bd5e473c88aa3bc5c046a761491d" 
}

Reference: http://php.net/manual/en/imagick.identifyimage.php
 

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32514 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6892 POSTS0 COMMENTS
Nicole Veronica
12012 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12107 POSTS0 COMMENTS
Shaida Kate Naidoo
7016 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6975 POSTS0 COMMENTS
Umr Jansen
6963 POSTS0 COMMENTS