public function generateFromSrc($src)
{
$matches = array();
if (!preg_match('#^([0-9]+)x([0-9]+)/([_a-z0-9]+)/([-_.:~%|a-zA-Z0-9]+)$#', $src, $matches)) {
return;
}
list(, $width, $height, $specs, $imagePath) = $matches;
$destFolder = rtrim($this->config['cache_path'], '/') . '/' . dirname(ltrim($src, './'));
if (!realpath($destFolder)) {
mkdir($destFolder, 0755, true);
}
if (!is_dir($destFolder)) {
throw new \RuntimeException("Can't create folder '{$destFolder}'.");
}
$rendition = new Rendition($width, $height, $specs);
$image = $rendition->generateImage($this->decodePath($imagePath));
$image->save($destFolder . '/' . $imagePath, array('quality' => 90));
return $image;
}