예제 #1
0
 public function testModifyEnlarginImage()
 {
     $width = 400;
     $height = 400;
     $image = m::mock('kingjerod\\ImageTools\\Image\\Image');
     $imagick = m::mock('Imagick');
     $image->shouldReceive('getImagick')->once()->andReturn($imagick);
     $imagick->shouldReceive('getimagewidth')->andReturn(200);
     $imagick->shouldReceive('getimageheight')->andReturn(200);
     $imagick->shouldReceive('resizeimage')->with($width, $height, Scale::FILTER_MITCHELL, 1)->once();
     $scale = new Scale($width, $height);
     $scale->modify($image);
 }
예제 #2
0
 public function modify(Image $image)
 {
     $imagick = $image->getImagick();
     $width = $imagick->getImageWidth();
     $height = $imagick->getImageHeight();
     $this->height = $height * $this->percentHeight;
     $this->width = $width * $this->percentWidth;
     parent::modify($image);
 }
예제 #3
0
 public function modify(Image $image)
 {
     $imagick = $image->getImagick();
     $width = $imagick->getImageWidth();
     $height = $imagick->getImageHeight();
     $widthRatio = $this->maxWidth / $width;
     $heightRatio = $this->maxHeight / $height;
     if ($widthRatio < $heightRatio) {
         //Scale by width
         $this->height = $widthRatio * $height;
         $this->width = $this->maxWidth;
         parent::modify($image);
     } else {
         //Scale by height
         $this->width = $heightRatio * $width;
         $this->height = $this->maxHeight;
         parent::modify($image);
     }
 }