/**
  * 
  */
 public function generateImages($nb)
 {
     for ($i = 0; $i < $nb; $i++) {
         $data = array('original_filename' => mt_rand() . '.jpg', 'filename' => md5(microtime()) . '.jpg', 'is_published' => rand(0, 1), 'mime_type' => 'image/jpg');
         $image = new sfImagePoolImage();
         $image->fromArray($data);
         $image->save();
         unset($image, $data);
     }
 }
 /**
  * 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;
 }