setWidth() public method

Set the width
public setWidth ( integer $width ) : Image
$width integer Width in pixels
return Image
Esempio n. 1
0
 /**
  * @dataProvider getParamsForWatermarks
  * @covers Imbo\Image\Transformation\Watermark::transform
  */
 public function testApplyToImageTopLeftWithOnlyWidthAndDefaultWatermark($params, $colors)
 {
     $blob = file_get_contents(FIXTURES_DIR . '/white.png');
     $image = new Image();
     $image->setBlob($blob);
     $image->setWidth($this->width);
     $image->setHeight($this->height);
     $transformation = $this->getTransformation();
     $transformation->setDefaultImage($this->watermarkImg);
     $expectedWatermark = $this->watermarkImg;
     if (isset($params['img'])) {
         $expectedWatermark = $params['img'];
     }
     $storage = $this->getMock('Imbo\\Storage\\StorageInterface');
     $storage->expects($this->once())->method('getImage')->with('someUser', $expectedWatermark)->will($this->returnValue(file_get_contents(FIXTURES_DIR . '/black.png')));
     $request = $this->getMock('Imbo\\Http\\Request\\Request');
     $request->expects($this->once())->method('getUser')->will($this->returnValue('someUser'));
     $event = new Event();
     $event->setArguments(['image' => $image, 'params' => $params, 'storage' => $storage, 'request' => $request]);
     $imagick = new Imagick();
     $imagick->readImageBlob($blob);
     $transformation->setImagick($imagick)->transform($event);
     foreach ($colors as $c) {
         $this->verifyColor($imagick, $c['x'], $c['y'], $c['colors']);
     }
 }
Esempio n. 2
0
 /**
  * @covers Imbo\Image\Transformation\SmartSize::transform
  * @dataProvider getSmartSizeArguments
  */
 public function testSmartSize($imageDimensions, $params, $cropParams)
 {
     $imagick = $this->getMock('Imagick');
     $imagick->expects($this->any())->method('cropImage')->with($cropParams['width'], $cropParams['height'], $cropParams['left'], $cropParams['top']);
     $image = new Image();
     $image->setWidth($imageDimensions['width']);
     $image->setHeight($imageDimensions['height']);
     $response = new Response();
     $event = $this->getMock('Imbo\\EventManager\\Event');
     $event->expects($this->at(0))->method('getArgument')->with('image')->will($this->returnValue($image));
     $event->expects($this->at(1))->method('getArgument')->with('params')->will($this->returnValue($params));
     $event->expects($this->at(2))->method('getResponse')->will($this->returnValue($response));
     $transformation = new SmartSize();
     $transformation->setImagick($imagick);
     $transformation->transform($event);
 }
Esempio n. 3
0
 /**
  * Resize the image
  *
  * @param Image $image The image to resize
  * @param int $targetWidth The resize target width
  * @param int $tartHeight The resize target height
  */
 private function resize(Image $image, $targetWidth, $targetHeight)
 {
     $this->imagick->setOption('jpeg:size', $targetWidth . 'x' . $targetHeight);
     $this->imagick->thumbnailImage($targetWidth, $targetHeight);
     $image->setWidth($targetWidth)->setHeight($targetHeight)->hasBeenTransformed(true);
 }
Esempio n. 4
0
 /**
  * {@inheritdoc}
  */
 public function load($publicKey, $imageIdentifier, Image $image)
 {
     $row = $this->getImageProperties($publicKey, $imageIdentifier);
     $image->setWidth($row['width'])->setHeight($row['height'])->setFilesize($row['size'])->setMimeType($row['mime'])->setExtension($row['extension'])->setAddedDate(new DateTime('@' . $row['added'], new DateTimeZone('UTC')))->setUpdatedDate(new DateTime('@' . $row['updated'], new DateTimeZone('UTC')));
     return true;
 }
Esempio n. 5
0
 /**
  * @covers Imbo\Model\Image::setWidth
  * @covers Imbo\Model\Image::getWidth
  */
 public function testCanSetAndGetWidth()
 {
     $width = 123;
     $this->assertSame($this->image, $this->image->setWidth($width));
     $this->assertSame($width, $this->image->getWidth());
 }