Esempio n. 1
0
 /**
  * (non-PHPdoc)
  * @param Image $image
  * @see \Image\Filter\ImageFilterInterface::filter()
  */
 public function filter(Image $image)
 {
     $width = $this->getWidth();
     $height = $this->getHeight();
     $tempimage = imagecreatetruecolor($width, $height);
     if (!imagecopyresampled($tempimage, $image->getSource(), 0, 0, 0, 0, $width, $height, $image->getWidth(), $image->getHeight())) {
         return false;
     }
     imagedestroy($image->getSource());
     $image->setSource($tempimage);
     $image->setWidth($width);
     $image->setHeight($height);
     return true;
 }
Esempio n. 2
0
 public function testImageInitialState()
 {
     $image = new Image('./module/Image/test/image.png', '');
     //$this->assertFalse($image->getSource());
     $this->assertEquals($image->getWidth(), 1499);
     $this->assertEquals($image->getHeight(), 803);
     $this->assertEquals($image->getMime(), 'image/png');
     $this->assertNull($image->getOutputFormat());
     $image->getSource();
     $this->assertEquals($image->getOutputFormat(), 'png');
 }
Esempio n. 3
0
File: Crop.php Progetto: sopin/image
 /**
  *
  * @param Image $image
  * @see \Image\Filter\Resize::filter()
  */
 public function filter(Image $image)
 {
     $aspect = $image->getHeight() / $this->getWidth();
     if (empty($this->getHeight())) {
         $this->setHeight($this->getWidth() / $aspect);
     }
     if (empty($this->getWidth())) {
         $this->setWidth($this->getHeight() * $aspect);
     }
     $tempimage = imagecreatetruecolor($this->getWidth(), $this->getHeight());
     if (!imagecopyresampled($tempimage, $image->getSource(), 0, 0, $this->getOffsetX(), $this->getOffsetY(), $this->getWidth(), $this->getHeight(), $this->getWidth(), $this->getHeight())) {
         return false;
     }
     imagedestroy($image->getSource());
     $image->setSource($tempimage);
     $image->setWidth($this->getWidth());
     $image->setHeight($this->getHeight());
     return true;
 }