Tuesday, October 7, 2025
HomeLanguagesPHP | Imagick identifyFormat() Function

PHP | Imagick identifyFormat() Function

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
      
    // Declare new Imagick object
    $imagick = new \Imagick(
      
    // Store a string into variable
    $embedText = "Output of 'Trim box: %@ number of unique colors: %k' is: <br/>";
      
    // Use Imagick::identifyFormat() function to replace the embedded
    // format characters with its appropriate image property
    $embedText .= $imagick->identifyFormat("Trim box: %@ number of unique colors: %k");
      
    // Display the output
    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

    Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
    Dominic
    Dominichttp://wardslaus.com
    infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
    RELATED ARTICLES

    Most Popular

    Dominic
    32340 POSTS0 COMMENTS
    Milvus
    86 POSTS0 COMMENTS
    Nango Kala
    6708 POSTS0 COMMENTS
    Nicole Veronica
    11872 POSTS0 COMMENTS
    Nokonwaba Nkukhwana
    11936 POSTS0 COMMENTS
    Shaida Kate Naidoo
    6829 POSTS0 COMMENTS
    Ted Musemwa
    7090 POSTS0 COMMENTS
    Thapelo Manthata
    6780 POSTS0 COMMENTS
    Umr Jansen
    6784 POSTS0 COMMENTS