Open In App

PHP | Gmagick profileimage() Function

Last Updated : 21 Jan, 2020
Summarize
Comments
Improve
Suggest changes
Share
Like Article
Like
Report
The Gmagick::profileimage() function is an inbuilt function in PHP which is used to add or remove a profile from an image. Syntax:
Gmagick Gmagick::profileimage( float $name, float $profile )
Parameters: This function accept two parameters as mentioned above and described below:
  • $name: It specifies the name of the profile.
  • $profile: It specifies the value of the profile.
Return Value: This function returns the Gmagick object with profile. Exceptions: This function throws GmagickException on error. Below given programs illustrate the Gmagick::profileimage() function in PHP: Used Image: Program 1 (Add profile): php
<?php

// Create a new Gmagick object
$gmagick = new Gmagick('geeksforgeeks.png');

// Add profile to the image
$gmagick->profileimage('my_profile_name', 'my_profile_value');

// Output the image  
echo $gmagick->getimageprofile('my_profile_name'); 
?>
Output:
my_profile_value
Program 2 (Remove profiles): php
<?php

// Create a new Gmagick object
$gmagick = new Gmagick('geeksforgeeks.png');

// Add profile to the image
$gmagick->profileimage('my_profile_name', 'my_profile_value');

// Remove all profiles
$gmagick->profileimage('*', NULL);

try {
    $profileValue = $gmagick->getimageprofile('my_profile_name'); 
} catch (\Throwable $e) {
    echo "No such profile exists";
}
?>
Output:
No such profile exists
Reference: https://www.php.net/manual/en/gmagick.profileimage.php

Next Article

Similar Reads