PHP | Imagick identifyFormat() Function
Last Updated :
08 Aug, 2019
The Imagick::identifyFormat() function is an inbuilt function in PHP which is used to replace the embedded format characters with its appropriate image property and returns the interpreted text.
List of escape sequence: Please refer the link to see the list of escape sequence. Ref: http://www.imagemagick.org/script/escape.php
Following are the some of the important embedded formatting characters such as escape sequences for appropriate image property:
%h current image height in pixels
%i image filename (note: becomes output filename for “info:”)
%k CALCULATED: number of unique colors
%m image file format (file magic)
%n number of images in current image sequence
%w current width in pixels
%x x resolution (density)
%y y resolution (density)
%z image depth (as read in unless modified, image save depth)
%U image resolution units
%@ CALCULATED: trim bounding box (without actually trimming) etc…
Syntax:
string Imagick::identifyFormat( $embedText )
Parameters: This function accepts single parameter $embedText which holds a string containing formatting sequences.
Return Value: This function returns the image format or FALSE on failure.
Below program illustrates the Imagick::identifyFormat() function in PHP:
Program: This program uses Imagick::identifyFormat() function to find the format of given Images.
<?php
$imagick = new \Imagick(
$embedText = "Output of 'Trim box: %@ number of unique colors: %k' is: <br/>" ;
$embedText .= $imagick ->identifyFormat( "Trim box: %@ number of unique colors: %k" );
echo $embedText ;
?>
|
Output:
Output of 'Trim box: %@ number of unique colors: %k' is:
Trim box: 656x144+5+15 number of unique colors: 2955
Reference: https://www.php.net/manual/en/imagick.identifyformat.php
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...