thumbnail() public method

This function attempts to get the image to as close to the provided dimensions as possible, and then crops the remaining overflow (from the center) to get the image to be the size specified. Useful for generating thumbnails.
public thumbnail ( integer $width, integer | null $height = null, boolean $topIsZero = false )
$width integer
$height integer | null If omitted - assumed equal to $width
$topIsZero boolean Force top offset = 0
コード例 #1
0
ファイル: ImageTest.php プロジェクト: Ruyan/Image
 public function testUnsupportedFormat()
 {
     $excepted = Helper::getExpected(__FUNCTION__ . '.png');
     $actual = Helper::getActual(__FUNCTION__ . '.tmp');
     $original = Helper::getOrig('1x1.tmp');
     if (copy($original, $actual)) {
         $img = new Image($actual);
         $info = $img->thumbnail(100, 200)->save()->getInfo();
         is('image/gif', $info['mime']);
         is(100, $info['width']);
         is(200, $info['height']);
         Helper::isFileEq($actual, $excepted);
     } else {
         fail('Can\'t copy original file!');
     }
 }