/** * @return ImagickContract|MockObject */ protected function imagick() : MockObject { if (empty($this->imagick)) { $this->imagick = $this->makeMock(ImagickContract::class); $this->imagick->expects($this->any())->method('getImage')->willReturn($this->imagick); } return $this->imagick; }
/** * @return ImagickContract */ private function waterMark() { if (!$this->waterMark->count()) { $this->waterMark->setBackgroundColor(new ImagickPixel('transparent')); $this->waterMark->readImage(resource_path(self::LOCATION)); } return $this->waterMark; }
/** * @param Image $image * * @return ImagickCollection */ public function preProcess(Image $image) : ImagickCollection { $this->imagick->readImage($image->storageLocation()); $this->imagick->setFilename($image->filename()); $collection = new ImagickCollection([$this->imagick]); foreach ($this->transformers as $transformer) { $transformer->applyTo($collection); } return $collection; }
/** * @param $sizeName * @param ImagickContract|Imagick $sized * * @return string */ private function sizedFilename(string $sizeName, $sized) : string { $pathInfo = pathinfo($sized->getFilename()); return "{$pathInfo['filename']}-{$sizeName}.{$pathInfo['extension']}"; }