/** * @param string $image_ * * @return \Components\Uri */ public static function uriForPath($image_) { $extension = Io::fileExtension($image_); $key = md5($image_); Cache::set($key, $image_); return Environment::uriComponents('ui', 'image', "{$key}.{$extension}"); }
/** * @param string $path_ * @param integer $width_ * @param integer $height_ * * @return string */ public static function imagePath($route_, Io_Path $path_, $width_ = null, $height_ = null) { $file = \str\encodeBase64Url(json_encode([(string) Io::path(Environment::pathWeb())->getRelativePath($path_), $width_, $height_])) . '.' . Io::fileExtension($path_); return Http_Router::path($route_) . "/{$file}"; }
/** * @see \Components\Io_Image_Engine::save() \Components\Io_Image_Engine::save() * * @return \Components\Io_Image_Engine_Gd */ public function save($path_, Io_Mimetype $type_ = null) { if (null === $type_) { $type_ = Io_Mimetype::forFileExtension(Io::fileExtension($path_)); } if (null === $type_) { $type_ = Io_Mimetype::IMAGE_PNG(); } $typeName = $type_->name(); if (false === isset(self::$m_saveHandler[$typeName])) { throw new Exception_NotSupported('io/image/engine/gd', sprintf('Saving to image of requested type is not supported [%s].', $type_)); } $directory = dirname($path_); if (false === is_dir($directory)) { Io::directoryCreate($directory); } $saveHandler = self::$m_saveHandler[$typeName]; $saveHandler($this->m_resource, $path_); return $this; }