예제 #1
0
 private function getGmagickImagine($file)
 {
     try {
         $imagine = new GmagickImagine();
         $image = $imagine->open($file);
     } catch (RuntimeException $e) {
         $this->markTestSkipped($e->getMessage());
     }
     return $image;
 }
예제 #2
0
 /**
  * @param string $origName
  * @param string $thumbName
  * @param array  $origInfo
  */
 public function resize($origName, $thumbName, array $origInfo)
 {
     if ($this->shouldResize($origInfo)) {
         $resizeParameters = $this->getResizeParameters($origInfo);
         $cropParameters = $this->getCropParameters($resizeParameters);
         $resizeSize = $this->factory->getBox($resizeParameters[0], $resizeParameters[1]);
         $cropStart = $this->factory->getPoint($cropParameters[0], $cropParameters[1]);
         $cropSize = $this->factory->getBox($this->thumbConfig[static::CONFIG_WIDTH], $this->thumbConfig[static::CONFIG_HEIGHT]);
         $this->imagine->open($origName)->resize($resizeSize)->crop($cropStart, $cropSize)->save($thumbName);
     } else {
         copy($origName, $thumbName);
     }
 }
예제 #3
0
 /**
  * Create a new ImageInterface instance from the given resource.
  *
  * @param mixed $resource Resource.
  *
  * @return \Webiny\Component\Image\ImageInterface
  */
 public function resource($resource)
 {
     return new Image($this->instance->read($resource));
 }
예제 #4
0
 /**
  * Opens image with Gmagick
  *
  * @return AbstractImage
  */
 protected function openWithGmagick()
 {
     $imagine = new GmagickImage();
     return $imagine->open($this->path);
 }