PHP | Gmagick removeimageprofile() Function
Last Updated :
14 Jan, 2020
The Gmagick::removeimageprofile() function is an inbuilt function in PHP which is used to remove the named image profile and returns it. This function works like the pop function of the stack data structure as it gives the value of profile and removes it from the image.
Syntax:
string Gmagick::removeimageprofile( string $name )
Parameters: This function accepts a single parameter $name which holds the name of profile to remove.
Return Value: This function returns a string value containing the value of the profile image.
Exceptions: This function throws GmagickException on error.
Below given programs illustrate the Gmagick::removeimageprofile() function in PHP:
Used Image:
Program 1:
<?php
$gmagick = new Gmagick( 'geeksforgeeks.png' );
$gmagick ->setimageprofile( 'profile_name' , 'profile_value' );
echo '<b>Before removing:</b> <br>' ;
testProfile( $gmagick , 'profile_name' );
$gmagick ->removeimageprofile( 'profile_name' );
echo '<b>After removing:</b> <br>' ;
testProfile( $gmagick , 'profile_name' );
function testProfile( $gmagick , $name ) {
try {
$value = $gmagick ->getimageprofile( 'profile_name' );
echo 'Profile is available with name <i>' . $name .
' </i>and value <i>' . $value . '</i><br>' ;
} catch (Exception $e ) {
echo 'Profile is not available.<br>' ;
}
}
?>
|
Output:
Before removing:
Profile is available with name profile_name and value profile_value
After removing:
Profile is not available.
Program 2:
<?php
$gmagick = new Gmagick( 'geeksforgeeks.png' );
$gmagick ->setimageprofile( 'borderColor1' , 'green' );
$gmagick ->setimageprofile( 'borderColor2' , 'red' );
$gmagick ->borderImage( $gmagick ->getImageProfile( 'borderColor1' ), 6, 6);
$gmagick ->borderImage( $gmagick ->getImageProfile( 'borderColor2' ), 6, 6);
$gmagick ->removeimageprofile( 'borderColor1' );
$gmagick ->removeimageprofile( 'borderColor2' );
header( "Content-Type: image/png" );
echo $gmagick ;
?>
|
Output:
Reference: https://www.php.net/manual/en/gmagick.removeimageprofile.php
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...