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:

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:

Related Articles:

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



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
{"cc_re__cc_re__cc_by_sa_4_0": ["ogle.com/store/apps/details?id=free.programming.programming&amp;hl=en\"><div class=\"social-img-div\"></div></a>\r\n                        <a class=\"social-link\" href=\"https://twitter.com/geeksforgeeks\"><div class=\"social-img-div\"></div></a>\r\n                        <a class=\"social-link\" href=\"https://www.youtube.com/geeksforgeeksvideos\"><div class=\"social-img-div\"></div></a>\r\n                    </li>\r\n                </ul>\r\n  </div>\r\n  <div class=\"footer-bottom-div\">\r\n            @geeksforgeeks, <a style=\"color:#fff !important\" href=\"https://creativecommons.org/licenses/by-sa/4.0/\">Some rights reserved</a>\r\n        </div>\r\n\r\n    </div>\r\n</footer>\r\n</div><!-- #page -->\r\n\r\n<script type='text/javascript' src='https://www.geeksforgeeks.org/wp-includes/js/wp-embed.min.js?ver=4.9.8'></script>\n\r\n<style>\r\n.eventLink{\r\nborder: 1px solid #868686;\r\nbackground-color: #e0e0e0;\r\npadding: 10px;\r\nbox-shadow: none;\r\ndisplay: block;\r\ntext-align: center;\r\ncolor: #555 !important;\r\nfont-size: 14px;\r\nfont-weight: bold;\r\n}\r\n</style>\r\n\r\n<script type=\"text/javascript\">\r\n// below changes to be adde"]}