/** * Creates a Thumbnail named by md5-hash of the image * and its file ending. * * @param mixed sfFilebasePluginImage $fileinfo * @param array $dimensions = array(width, height) */ public function createThumbnail(sfFilebasePluginImage $fileinfo, array $dimensions, $quality, $mime, $preserve_transparency = true) { // Check cache directory if (!$this->filebase->getCacheDirectory()->fileExists()) { throw new sfFilebasePluginException(sprintf('Cache directory %s does not exist.', $this->filebase->getCacheDirectory()->getPathname())); } // Check if original file is writable... if (!$fileinfo->fileExists()) { throw new sfFilebasePluginException(sprintf('File %s does not exist', $fileinfo->getPathname())); } if (!$fileinfo->isReadable()) { throw new sfFilebasePluginException(sprintf('File %s is write protected.', $fileinfo->getPathname())); } if (!$this->filebase->getIsSupportedImage($fileinfo)) { throw new sfFilebasePluginException(sprintf('File %s is not an image.', $fileinfo)); } if (!$fileinfo->isImage()) { throw new sfFilebasePluginException(sprintf('Image format %s is unsupported.', $fileinfo)); } if (!$this->filebase->isInFilebase($fileinfo)) { throw new sfFilebasePluginException(sprintf('FilebaseFile %s does not belong to Filebase %s, cannot be deleted due to security issues', $fileinfo->getPathname(), $this->filebase->getPathname())); } $destination = $this->getThumbnailFileinfo($fileinfo, $dimensions, $mime); return new sfFilebasePluginThumbnail($this->imageCopyResampled($fileinfo, $destination, $dimensions, true, $preserve_transparency), $this->filebase, $fileinfo); }