Open In App

PHP | Gmagick profileimage() Function

Last Updated : 21 Jan, 2020
Improve
Improve
Like Article
Like
Save
Share
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
  
// 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
  
// 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



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads