Well, among new features of imagick there is cropThumbnailImage. It’s not really that new but it might be undocumented for most of the parts.
- /* Read the image */
- $im = new imagick( "test.png" );
- /* create the thumbnail */
- $im->cropThumbnailImage( 80, 80 );
- /* Write to a file */
- $im->writeImage( "th_80x80_test.png" );
Let’s assume the source image in this example is 120×240. First it is scaled down to 80×160 and then cropped by the larger side (height in this case) from position x0,y40 to x80,y120. After this crop we have a fixed size 80×80 thumbnail.