thumbnail() public static method

If one of thumbnail dimensions is set to null, another one is calculated automatically based on aspect ratio of original image. Note that calculated thumbnail dimension may vary depending on the source image in this case. If both dimensions are specified, resulting thumbnail would be exactly the width and height specified. How it's achieved depends on the mode. If ImageInterface::THUMBNAIL_OUTBOUND mode is used, which is default, then the thumbnail is scaled so that its smallest side equals the length of the corresponding side in the original image. Any excess outside of the scaled thumbnail’s area will be cropped, and the returned thumbnail will have the exact width and height specified. If thumbnail mode is ImageInterface::THUMBNAIL_INSET, the original image is scaled down so it is fully contained within the thumbnail dimensions. The rest is filled with background that could be configured via [[Image::$thumbnailBackgroundColor]] and [[Image::$thumbnailBackgroundAlpha]].
public static thumbnail ( string | resource | Imagine\Image\ImageInterface $image, integer $width, integer $height, string $mode = ManipulatorInterface::THUMBNAIL_OUTBOUND ) : Imagine\Image\ImageInterface
$image string | resource | Imagine\Image\ImageInterface either ImageInterface, resource or a string containing file path
$width integer the width in pixels to create the thumbnail
$height integer the height in pixels to create the thumbnail
$mode string mode of resizing original image to use in case both width and height specified
return Imagine\Image\ImageInterface
Example #1
0
 protected function _resize($size, $width, $height, $quality)
 {
     $original = static::_server_path('original', FALSE);
     $resize = static::_server_path($size);
     BaseImage::thumbnail($original, $width, $height)->save($resize, ['quality' => $quality]);
 }