Open In App

PHP | Imagick getImageAttribute() Function

Last Updated : 15 Nov, 2019
Comments
Improve
Suggest changes
Like Article
Like
Report

The Imagick::getImageAttribute() function is an inbuilt function in PHP which is used to get the named attribute of a key.

Syntax:

string Imagick::getImageAttribute( string $key )

Parameters: This function accepts single parameter $key which holds the key value in string format.

Return Value: This function returns a string value on success.

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

Program 1:




<?php
  
// Create a Imagick object
$imagick = new Imagick(
  
// Get the attribute with key 'hello'
$attribute = $imagick->getImageAttribute('hello');
  
echo $attribute;
?>


Output:

Empty string as it is the default value. 

Program 2:




<?php
  
// Create a Imagick object
$imagick = new Imagick(
  
// Set an attribute with key 'hello'
$imagick->setImageAttribute('hello', 'world');
  
// Get the attribute with key 'hello'
$attribute = $imagick->getImageAttribute('hello');
  
echo $attribute;
?>


Output:

world

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



Next Article

Similar Reads