/**
  * Generates a thumbnail.
  *
  * The generation is actually done by the sfImageTransformPlugin. This method only collects the
  * options configured in the thumbnailing.yml and uses them to call sfImageTransformPlugins transformations.
  * Additionally the generated thumbnail can be cached.
  *
  * @param  string  $uri     Image source URI (sfImageSource://...)
  * @param  array   $options Thumbnail parameters taken from the thumbnail URL referencing a format and id
  * @return sfImage
  */
 public function generate($uri, $format)
 {
     if (!array_key_exists($format, $this->options['formats'])) {
         throw new sfImageTransformExtraPluginConfigurationException('Unknown format "' . $format . '" in your thumbnailing.yml!');
     }
     $sourceImage = new sfImage($uri);
     $settings = $this->options['formats'][$format];
     if (array_key_exists('mime_type', $settings)) {
         $sourceImage->setMIMEType($settings['mime_type']);
     }
     if (is_array($settings['transformations'])) {
         foreach ($settings['transformations'] as $transformation) {
             $this->transform($sourceImage, $transformation);
         }
     }
     $sourceImage->setQuality($settings['quality']);
     return $sourceImage;
 }