Open In App

PHP | Imagick stripImage() Function

Last Updated : 17 Dec, 2019
Comments
Improve
Suggest changes
Like Article
Like
Report
The Imagick::stripImage() function is an inbuilt function in PHP which is used to strip all profiles and comments from an image. Syntax:
bool Imagick::stripImage( void )
Parameters:This function doesn’t accepts any parameter. Return Value: This function returns TRUE on success. Exceptions: This function throws ImagickException on error. Below given programs illustrate the Imagick::stripImage() function in PHP: Program 1: php
<?php

// Create a new imagick object
$imagick = new Imagick(
'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-13.png');

// Set some profiles
$imagick->setImageProfile('name1', 'value1');
$imagick->setImageProfile('name2', 'value2');

echo 'Before stripImage() function: <br>';
print("<pre>" . print_r($imagick->
                        getImageProfiles(), true)
              . "</pre><br>");

// Strip the image
$imagick->stripImage();

echo 'After stripImage() function: <br>';
print("<pre>" . print_r($imagick->
                        getImageProfiles(), true)
              . "</pre>");
?>
Output:
Before stripImage() function:
Array
(
    [name1] => value1
    [name2] => value2
)

After stripImage() function:
Array
(
)
Program 2: php
<?php
 
// Create a new imagick object
$imagick = new Imagick(
'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-13.png');
 
// Add a comment
$imagick->commentImage("This is my comment.");
 
echo 'Before stripImage() function: <br>';
print("<pre>" . print_r($imagick->
                        getImageProperty("comment"), true) 
              . "</pre><br>");
 
// Strip the image
$imagick->stripImage();
 
echo 'After stripImage() function: <br>';
print("<pre>" . print_r($imagick->
                        getImageProperty("comment"), true) 
              . "</pre><br>");
?>
Output:
Before stripImage() function:
This is my comment.

After stripImage() function:
Reference: https://www.php.net/manual/en/imagick.stripimage.php

Next Article

Similar Reads