PHP | Imagick getImageProfile() Function
Last Updated :
26 Nov, 2019
Improve
The Imagick::getImageProfile() function is an inbuilt function in PHP which is used to return the named image profile.
Syntax:
php
Output:
php
Output:
Reference: https://www.php.net/manual/en/imagick.getimageprofile.php
string Imagick::getImageProfile( string $name )Parameters: This function accepts a single parameter $name which holds the name of profile. Return Value: This function returns a string containing the image profile. Errors/Exceptions: This function throws ImagickException on error. Below programs illustrate the Imagick::getImageProfile() function in PHP: Program 1:
<?php
// Create a new imagick object
$imagick = new Imagick(
'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-13.png');
// Set the Image Profile
$imagick->setImageProfile('profile_name', 'profile_data');
// Get the Image Profile
$profile = $imagick->getImageProfile('profile_name');
echo $profile;
?>
profile_dataProgram 2:
<?php
// Create a new imagick object
$imagick = new Imagick(
'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-13.png');
// Set the Image Profile
$imagick->setImageProfile('color', 'red');
// Use the Image Profile
$imagick->setImageBackgroundColor($imagick->getImageProfile('color'));
$imagick->setImageAlphaChannel(Imagick::ALPHACHANNEL_SHAPE);
// Display the image
header("Content-Type: image/png");
echo $imagick->getImageBlob();
?>
