Example #1
0
 /**
  * @param Utils\Image|string $sourceFile
  * @param string $name
  * @param string $resolution
  * @param int $method
  * @return ImagePath
  */
 public function saveFile($sourceFile, $name, $resolution, $method)
 {
     $filename = $this->path->getFilesystem($name, $resolution, $method);
     Utils\FileSystem::createDir(dirname($filename));
     if ($sourceFile instanceof Utils\Image) {
         $resolutionArray = explode('x', $resolution);
         $sourceFile->resize($resolutionArray[0], $resolutionArray[1], (int) $method)->save($filename);
     } elseif (!$this->download->save($sourceFile, $filename)) {
         throw new ImageManager\RemoteFileDoesNotExistsException($sourceFile);
     }
     return new ImagePath($this->getPathUrl($name, $resolution, $method), $filename);
 }
Example #2
0
 /**
  * @param string $name
  * @param string $resolution
  * @param int $method
  * @throws ImageManager\ResolutionIsNotAllowedException
  * @throws ImageManager\RemoteFileDoesNotExistsException
  * @return bool
  */
 public function send($name, $resolution, $method)
 {
     $this->checkResolution($resolution);
     $imagePath = $this->createImagePath($name, $resolution, $method);
     if ($imagePath->fs) {
         Utils\Image::fromFile($imagePath->fs)->send();
         return TRUE;
     } elseif ($imagePath->url) {
         Utils\Image::fromString($this->download->loadFromUrl($imagePath->url))->send();
         return TRUE;
     }
     return FALSE;
 }