Exemplo n.º 1
0
 protected function _save($writePath)
 {
     try {
         MagickSetImageColorspace($this->_resource, MW_RGBColorspace);
         MagickSetCompression($this->_resource, MW_JPEGCompression);
         MagickSetCompressionQuality($this->_resource, 85);
         MagickSetImageFormat($this->_resource, 'jpeg');
         MagickWriteImage($this->_resource, $writePath);
     } catch (Exception $e) {
         throw new Bbx_Media_Image_Processor_Exception('Couldn\'t write image to ' . $writePath);
     }
 }
Exemplo n.º 2
0
 /**
  * Image Process Using MagickWand
  *
  * This function will resize, crop or rotate
  *
  * @access	public
  * @auth	John Meng
  * @param	string
  * @return	bool
  */
 function image_process_magickwand($action = 'resize')
 {
     if (!file_exists($this->full_src_path)) {
         $this->set_error("Image source file not found!");
         return false;
     }
     if (file_exists($this->full_dst_path)) {
         @unlink("{$this->full_dst_path}");
     }
     $magick_wand = NewMagickWand();
     MagickRemoveImageProfiles($magick_wand);
     MagickSetCompressionQuality($magick_wand, $this->quality);
     MagickReadImage($magick_wand, $this->full_src_path);
     switch ($action) {
         case 'crop':
             MagickCropImage($magick_wand, $this->width, $this->height, $this->x_axis, $this->y_axis);
             break;
         case 'rotate':
             switch ($this->rotation_angle) {
                 case 90:
                     $angle = 90;
                     break;
                 case 180:
                     $angle = 180;
                     break;
                 case 270:
                     $angle = 270;
                     break;
                 case 'vrt':
                     $angle = 180;
                     break;
                 case 'hor':
                     $angle = 270;
                     break;
             }
             MagickRotateImage($magick_wand, null, $angle);
             break;
         case 'resize':
         default:
             MagickResizeImage($magick_wand, $this->width, $this->height, MW_LanczosFilter, 1.0);
             break;
     }
     MagickWriteImage($magick_wand, $this->full_dst_path);
     DestroymagickWand($magick_wand);
     // Set the file to 777
     @chmod($this->full_dst_path, $this->dir_write_mode);
     return TRUE;
 }