Sunday, October 5, 2025
HomeLanguagesPHP | Imagick trimImage() Function

PHP | Imagick trimImage() Function

The Imagick::trimImage() function is an inbuilt function in PHP which is used to remove the edges from the image.

Syntax:

bool Imagick::trimImage( $fuzz )

Parameters: This function accepts single parameter $fuzz. The fuzz member of image defines how much tolerance is acceptable to consider two colors as the same. This parameter represents the variation on the quantum range.

Return Value: This function returns True on success. 

Errors/Exceptions: This function throws ImagickException on error. Below program illustrates the Imagick::trimImage() function in PHP: 

Program: 

php




?php
 
// Create an Imagick object
$imagick = new Imagick(
 
// Trim the image.
$imagick->trimImage(0);
 
// Output the image
header("Content-Type: image/" . $imagick->getImageFormat());
echo $imagick;
?>


Output:

 trim image

Related Articles:

Reference: http://php.net/manual/en/imagick.trimimage.php

RELATED ARTICLES

Most Popular

Dominic
32337 POSTS0 COMMENTS
Milvus
86 POSTS0 COMMENTS
Nango Kala
6707 POSTS0 COMMENTS
Nicole Veronica
11871 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11936 POSTS0 COMMENTS
Shaida Kate Naidoo
6823 POSTS0 COMMENTS
Ted Musemwa
7089 POSTS0 COMMENTS
Thapelo Manthata
6779 POSTS0 COMMENTS
Umr Jansen
6779 POSTS0 COMMENTS