Ejemplo n.º 1
0
 /**
  * @return RokGallery_FileCreQueue
  */
 public function &getInstance()
 {
     if (!isset(self::$_instance)) {
         self::$_instance = new RokGallery_Queue_FileCreate();
     }
     return self::$_instance;
 }
Ejemplo n.º 2
0
 /**
  * @param Doctrine_Event $event
  */
 public function postTransactionRollback(Doctrine_Event $event)
 {
     RokGallery_Queue_FileDelete::clear();
     RokGallery_Queue_DirectoryDelete::clear();
     RokGallery_Queue_FileCreate::process();
     RokGallery_Queue_DirectoryCreate::process();
 }
Ejemplo n.º 3
0
 /**
  * Generates a thumbnail image for a slice
  *
  * @param $thumb_x
  * @param $thumb_y
  * @param bool $keep_aspect
  * @param null $background_color
  * @param string $extension
  *
  */
 public function generateThumbnail($thumb_x, $thumb_y, $keep_aspect = true, $background_color = null, $extension = "thumb")
 {
     $slices_dir = dirname($this->File->getFullPath());
     $thumb_path = $this->getThumbFullPath($extension);
     // get the slice image
     RokGallery_Memory::adjustLimitForImage($this->xsize, $this->ysize);
     $slice_image = WideImage::loadFromFile($this->getFullPath());
     if ($background_color == 'transparent' || empty($background_color)) {
         $background_color = null;
     }
     // if he image size is smaller then the thumbnail size
     // resize the canvas with optioned color and place in center
     if ($this->xsize < $thumb_x && $this->ysize < $thumb_y) {
         // Resize canvas
         RokGallery_Memory::adjustLimitForImage($thumb_x, $thumb_y);
         $thumb_image = $slice_image->resizeCanvas($thumb_x, $thumb_y, 'center', 'center', $background_color == null ? $background_color : $slice_image->allocateColor(RokGallery_Helper::html2rgb($background_color)));
         $slice_image->destroy();
         unset($slice_image);
         // write out image
         $thumb_image->saveToFile($thumb_path, RokGallery_Helper::getImageQuality($this->File->type));
         RokGallery_Queue_FileCreate::add($thumb_path);
         $thumb_image->destroy();
         unset($thumb_image);
     } else {
         if ($keep_aspect) {
             // Keep the aspect Ratio
             RokGallery_Memory::adjustLimitForImage($thumb_x, $thumb_y);
             $thumb_image_after_resize = $slice_image->resize($thumb_x, $thumb_y);
             $slice_image->destroy();
             unset($slice_image);
             // fill in blank space
             RokGallery_Memory::adjustLimitForImage($thumb_x, $thumb_y);
             $thumb_image = $thumb_image_after_resize->resizeCanvas($thumb_x, $thumb_y, 'center', 'center', $background_color == null ? $background_color : $thumb_image_after_resize->allocateColor(RokGallery_Helper::html2rgb($background_color)));
             $thumb_image_after_resize->destroy();
             unset($thumb_image_after_resize);
             // write out image
             $thumb_image->saveToFile($thumb_path, RokGallery_Helper::getImageQuality($this->File->type));
             RokGallery_Queue_FileCreate::add($thumb_path);
             $thumb_image->destroy();
             unset($thumb_image);
         } else {
             // Create thumbnail but dont make thumbnail keep the aspect ratio
             $source_aspect_ratio = $this->xsize / $this->ysize;
             $desired_aspect_ratio = $thumb_x / $thumb_y;
             $temp_width = $thumb_x;
             $temp_height = $thumb_y;
             $temp_left = 0;
             $temp_top = 0;
             if ($source_aspect_ratio > $desired_aspect_ratio) {
                 $temp_height = $thumb_y;
                 $temp_width = (int) round($thumb_y * $source_aspect_ratio);
                 $temp_left = (int) round(($temp_width - $thumb_x) / 2);
                 $temp_top = 0;
             } elseif ($source_aspect_ratio < $desired_aspect_ratio) {
                 $temp_width = $thumb_x;
                 $temp_height = (int) round($thumb_x / $source_aspect_ratio);
                 $temp_left = 0;
                 $temp_top = (int) round(($temp_height - $thumb_y) / 2);
             }
             RokGallery_Memory::adjustLimitForImage($temp_width, $temp_height);
             $thumb_image_after_resize = $slice_image->resize($temp_width, $temp_height);
             $slice_image->destroy();
             unset($slice_image);
             RokGallery_Memory::adjustLimitForImage($thumb_x, $thumb_y);
             $thumb_image = $thumb_image_after_resize->crop($temp_left, $temp_top, $thumb_x, $thumb_y);
             $thumb_image_after_resize->destroy();
             unset($thumb_image_after_resize);
             // write out image
             $thumb_image->saveToFile($thumb_path, RokGallery_Helper::getImageQuality($this->File->type));
             RokGallery_Queue_FileCreate::add($thumb_path);
             $thumb_image->destroy();
             unset($thumb_image);
         }
     }
 }