/** * @param string $name * @param string $resolution * @param int $method * @return ImagePath */ public function createImagePath($name, $resolution, $method) { $thumbFile = $this->path->getFilesystem($name, $resolution, $method); if (is_file($thumbFile)) { return new ImagePath($this->getPathUrl($name, $resolution, $method), $thumbFile); } $sourceImage = $this->path->getSourceDir($name); if (!is_file($sourceImage)) { return $this->placehold->createImagePath($resolution); } return $this->saveFile(Utils\Image::fromFile($sourceImage), $name, $resolution, $method); }
/** * @param Utils\Image $image * @param string $path * @param string $extension * @return Image */ public function saveImage(Utils\Image $image, $path, $extension) { do { $relativePath = self::addSlashPath($path) . md5(microtime()) . '.' . strtolower($extension); $filename = $this->path->getSourceDir($relativePath); } while (is_file($filename)); if ($this->maxSize) { $image->resize($this->maxSize['width'], $this->maxSize['height'], Utils\Image::SHRINK_ONLY); } Utils\FileSystem::createDir(dirname($filename)); $image->save($filename); return new Image($this->path->getSourceDir(''), $relativePath); }