/**
  * Return path to new image on filesystem. Creates folders if they don't exist.
  *
  * @return string
  */
 public function getDestination()
 {
     $folder_path = implode(DIRECTORY_SEPARATOR, array(sfImagePoolPluginConfiguration::getBaseDir(), $this->resizer_options['scale'] ? 'scale' : 'crop', $this->resizer_options['width'], $this->resizer_options['height']));
     // if folder not found for this resize, then attempt to create it.
     if (!file_exists($folder_path)) {
         if (!mkdir($folder_path, 0777, true)) {
             throw new sfImagePoolException(sprintf('Could not create "%s"', $folder_path));
         }
     }
     return $folder_path . DIRECTORY_SEPARATOR . $this->image['filename'];
 }
 /**
  * Take array of data for a single upload and create an image, assigning
  * content of $tags as tag (CSV string or single tag or array).
  * 
  * This common logic is abstracted out so it can easily be used by other plugins
  * that require image upload but need to handle the actual upload logic themselves.
  * 
  * @param array $upload
  * @param mixed $tags
  * @return sfImagePoolImage
  */
 public static function createImageFromUpload($upload, $tags = null)
 {
     // upload was ok, mime type ok and file isn't too big so let's move it into the image pool
     // location and then create a new object for it.
     $file = new sfValidatedFile($upload['name'], $upload['type'], $upload['tmp_name'], $upload['size'], sfImagePoolPluginConfiguration::getBaseDir());
     // this will generate the unique filename
     $new_filename = $file->save();
     $image_data = array('original_filename' => $file->getOriginalName(), 'filename' => $new_filename, 'mime_type' => $file->getType());
     $image = new sfImagePoolImage();
     $image->fromArray($image_data);
     // now set tags if they've been supplied
     if ($tags) {
         $image->addTag($tags);
     }
     $image->save();
     return $image;
 }
 /**
  * Return path to folder where originals are stored.
  * 
  * @return string
  */
 public function getUploadDir()
 {
     return sfImagePoolPluginConfiguration::getBaseDir();
 }
 /**
  * Get the path to the original file
  * @return string
  */
 public function getPathToOriginalFile()
 {
     return implode(DIRECTORY_SEPARATOR, array(sfImagePoolPluginConfiguration::getBaseDir(), $this['filename']));
 }