I found a relevant posting complete with demo code at this site:
http://valokuva.org/?p=8
Sample code goes like this:
<?php
/* 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" );
?>
This is a specialization of the cropImage method. At a high level, this method will create a thumbnail of a given image, with the thumbnail sized at ($width, $height).
If the thumbnail does not match the aspect ratio of the source image, this is the method to use. The thumbnail will capture the entire image on the shorter edge of the source image (ie, vertical size on a landscape image). Then the thumbnail will be scaled down to meet your target height, while preserving the aspect ratio. Extra horizontal space that does not fit within the target $width will be cropped off evenly left and right.
As a result, the thumbnail is usually a good representation of the source image.
Imagick::cropThumbnailImage
(PECL imagick 2.0.0)
Imagick::cropThumbnailImage — Creates a crop thumbnail
설명
bool Imagick::cropThumbnailImage
( int $width
, int $height
)
Warning
이 함수는 현재 문서화 되어있지 않습니다; 인수 목록만을 제공합니다.
Creates a fixed size thumbnail by first scaling the image down and cropping a specified area from the center.
인수
- width
-
The width of the thumbnail
- height
-
The Height of the thumbnail
반환값
성공시에 TRUE를 반환합니다.
오류/예외
오류시에 ImagickException이 발생합니다.
Imagick::cropThumbnailImage
benford at bluhelix dot com
11-Jun-2009 09:14
11-Jun-2009 09:14
domenechs1 at yahoo dot es
03-Mar-2008 05:06
03-Mar-2008 05:06
$image = new Imagick($path."test1.jpg");
$image->cropThumbnailImage(160,120); // Crop image and thumb
$image->writeImage($path."test1.jpg");
