/** * Create a thumbnail of the source $file with given $transforms * @param string $file Source File (see $this->processFile()'s return value) * @param Transforms\AbstractTransform[] $transforms Transforms ro be applied * @return string|bool Thumb url or false on fail */ public function createThumb($file, $transforms = []) { $finfo = pathinfo($file); $relDir = $this->getFileDir($file); $thbPath = "/{$relDir}/" . $finfo['filename'] . Helper::serializeTransforms($transforms) . '.' . $finfo['extension']; if (is_dir($this->_baseThumb . "/{$relDir}")) { if (file_exists($this->_baseThumb . $thbPath)) { return $this->_webThumb . $thbPath; } } elseif (!mkdir($this->_baseThumb . "/{$relDir}", 0775, true)) { return false; } $imagine = $this->getImagine(); $image = $imagine->open($this->_baseSrc . "/{$relDir}/{$file}"); foreach ($transforms as $transform) { $transform->apply($image, $imagine); } $image->save($this->_baseThumb . $thbPath, ['quality' => 90]); return $this->_webThumb . $thbPath; }