HomeLanguagesPHP | Imagick stripImage() Function

PHP | Imagick stripImage() Function

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

RELATED ARTICLES

Most Popular

Dominic
32688 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
7057 POSTS0 COMMENTS
Nicole Veronica
12198 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12293 POSTS0 COMMENTS
Shaida Kate Naidoo
7182 POSTS0 COMMENTS
Ted Musemwa
7447 POSTS0 COMMENTS
Thapelo Manthata
7160 POSTS0 COMMENTS
Umr Jansen
7150 POSTS0 COMMENTS