PHP | Imagick getImageProperties() Function

The Imagick::getImageProperties() function is an inbuilt function in PHP which is used to get the image properties.

Syntax:

array Imagick::getImageProperties( string $pattern, string $includes_values )

Parameters: This function accepts two parameters as mentioned above and described below:



  • $pattern: It specifies pattern for property names. Default value is * which returns all the properties.
  • $includes_values: It specifies whether to return only property names. Its default values is TRUE. If FALSE then only property names will be returned.

Return Value: This function returns an array containing the image properties or just property names.

Below programs illustrate the Imagick::getImageProperties() function in PHP:

Program 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
  
// Create a new imagick object
$imagick = new Imagick(
  
// Set the Image Properties
$imagick->setImageProperty('property1', 'value1');
$imagick->setImageProperty('property2', 'value2');
$imagick->setImageProperty('hello', 'world');
  
// Get the Image Profiles without values starting from "pro"
$properties = $imagick->getImageProperties("pro*", false);
print("<pre>".print_r($properties, true)."</pre>");
?>

chevron_right


Output:

Array
(
    [0] => property1
    [1] => property2
)

Program 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
  
// Create a new imagick object
$imagick = new Imagick(
  
// Set the Image Properties
$imagick->setImageProperty('property1', 'value1');
$imagick->setImageProperty('property2', 'value2');
  
// Get the Image Profiles
$properties = $imagick->getImageProperties("*");
print("<pre>".print_r($properties, true)."</pre>");
?>

chevron_right


Output:

Array
(
    [date:create] => 2019-11-21T22:32:52+05:00
    [date:modify] => 2019-11-21T22:32:52+05:00
    [png:cHRM] => chunk was found (see Chromaticity, above)
    [png:gAMA] => gamma=0.45455 (See Gamma, above)
    [png:IHDR.bit-depth-orig] => 8
    [png:IHDR.bit_depth] => 8
    [png:IHDR.color-type-orig] => 6
    [png:IHDR.color_type] => 6 (RGBA)
    [png:IHDR.interlace_method] => 0 (Not interlaced)
    [png:IHDR.width, height] => 667, 184
    [png:pHYs] => x_res=3780, y_res=3780, units=1
    [png:sRGB] => intent=0 (Perceptual Intent)
    [png:text] => 1 tEXt/zTXt/iTXt chunks were found
    [property1] => value1
    [property2] => value2
    [Software] => Adobe ImageReady
)

Reference: https://www.php.net/manual/en/imagick.getimageproperties.php




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.