PHP | Gmagick profileimage() Function

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):

filter_none

edit
close

play_arrow

link
brightness_4
code

<?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'); 
?>

chevron_right


Output:

my_profile_value

Program 2 (Remove profiles):

filter_none

edit
close

play_arrow

link
brightness_4
code

<?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";
}
?>

chevron_right


Output:

No such profile exists

Reference: https://www.php.net/manual/en/gmagick.profileimage.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.