PHP | Imagick cropThumbnailImage() Function
The Imagick::cropThumbnailImage() function is an inbuilt function in PHP which is used to create a cropped thumbnail. This function creates a fixed-size thumbnail by first scaling the image up or down with height and weight parameters, and then cropping an area from the center of the image.
Note: Using cropThumbnailImage() function can appear to give undesired results while using .gif image formats. If you are using .gif, you need to compliment this function with the removal of the canvas.
Syntax:
bool Imagick::cropThumbnailImage( $width, $height, $legacy = FALSE )
Parameters: This function accept two parameters as mentioned above and described below:
- $width: This parameter holds the width of the thumbnail.
- $height: This parameter holds the height of the thumbnail.
Return Value: This function returns True on success.
Errors/Exceptions: This function throws ImagickException on error.
Original Image:

Below program illustrates the Imagick::cropThumbnailImage() function in PHP:
Program:
<?php // Create a new object $image = new Imagick( // Crop and resize the image $image -> cropThumbnailImage(300, 50); // Remove the canvas using the line below // if the image is a .gif file: // $image->setImagePage(0, 0, 0, 0); // Image header header('Content-type: image/png'); // Display resulting image: echo $image; ?> |
Output:

Reference: https://www.php.net/manual/en/imagick.cropthumbnailimage.php
Recommended Posts:
- PHP | Gmagick cropthumbnailimage() Function
- PHP | Imagick setImageChannelDepth() Function
- PHP | Imagick getImageBluePrimary() Function
- PHP | Imagick getImageChannelRange() Function
- PHP | Imagick shadeImage() Function
- PHP | Imagick magnifyImage() Function
- PHP | Imagick annotateImage() Function
- PHP | Imagick minifyImage() Function
- PHP | Imagick getImageChannelDepth() Function
- PHP | Imagick adaptiveSharpenImage() Function
- PHP | Imagick getQuantumDepth() Function
- PHP | Imagick getQuantumRange() Function
- PHP | Imagick transverseImage() Function
- PHP | Imagick getPackageName() Function
- PHP | Imagick getVersion() Function
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.



