PHP | Gmagick profileimage() Function
Last Updated :
21 Jan, 2020
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
$gmagick = new Gmagick( 'geeksforgeeks.png' );
$gmagick ->profileimage( 'my_profile_name' , 'my_profile_value' );
echo $gmagick ->getimageprofile( 'my_profile_name' );
?>
|
Output:
my_profile_value
Program 2 (Remove profiles):
<?php
$gmagick = new Gmagick( 'geeksforgeeks.png' );
$gmagick ->profileimage( 'my_profile_name' , 'my_profile_value' );
$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
Share your thoughts in the comments
Please Login to comment...