Open In App

PHP | Imagick stripImage() Function

Improve
Improve
Like Article
Like
Save
Share
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
  
// Create a new imagick object
$imagick = new Imagick(
  
// 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
   
// Create a new imagick object
$imagick = new Imagick(
   
// 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



Last Updated : 17 Dec, 2019
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads