Ejemplo n.º 1
0
 function testResize()
 {
     $config = array();
     $config['image_library'] = 'gd2';
     $config['source_image'] = dirname(dirname(__FILE__)) . DS . 'files' . DS . "hot_topic081218.jpg";
     $config['new_image'] = dirname(dirname(__FILE__)) . DS . 'files' . DS . "test.jpg";
     $config['create_thumb'] = TRUE;
     $config['maintain_ratio'] = TRUE;
     $config['width'] = 180;
     $config['height'] = 180;
     $img = new Image_Lib($config);
     $img->resize();
 }
Ejemplo n.º 2
0
 /**
  * Resize specify image file and cache in local file system
  *
  * @author	John Meng 2009-2-12
  * @access	public
  * @param	string		$image		specify image path
  * @param 	array		$params		resize operate option
  * @return	string		return after resize file web path
  */
 function thumb($image, $params = array())
 {
     $this->_initialize($params);
     if (empty($this->width) && empty($this->height)) {
         return $image;
     }
     //check cache the image TRUE or FALSE
     $this->image_file_md5 = $this->_getFilePathMD5($image);
     $file_name = $this->_getCacheFileName($image);
     $folder_path = $this->_getFilePath();
     $this->dest_absolute_file = $folder_path['real_path'] . $file_name;
     $this->dest_web_file = $folder_path['web_path'] . $file_name;
     if (!file_exists($this->dest_absolute_file)) {
         $config = array();
         $config['image_library'] = $this->image_library;
         $config['new_image'] = $this->dest_absolute_file;
         $config['maintain_ratio'] = $this->maintain_ratio;
         $config['width'] = $this->width;
         $config['height'] = $this->height;
         $pattern = "^http://";
         if (eregi($pattern, $image)) {
             // remote image
             $web_tmp_path = $folder_path['real_path'] . "tmp_" . $file_name;
             $this->_cacheWebFile($image, $web_tmp_path);
             $config['source_image'] = $web_tmp_path;
             $img_lib = new Image_Lib($config);
             $img_lib->resize();
             @unlink($web_tmp_path);
         } else {
             // localhost image
             $config['source_image'] = WWW_ROOT . IMAGES_URL . $image;
             $img_lib = new Image_Lib($config);
             $img_lib->resize();
         }
     }
     return $this->dest_web_file;
 }
Ejemplo n.º 3
0
 function _watermark()
 {
     $config = array();
     $config['image_library'] = $this->image_library;
     $config['source_image'] = $this->file['tmp_name'];
     $config['new_image'] = $this->dest_absolute_file;
     $config['wm_text'] = $this->wm_text;
     $config['wm_type'] = $this->wm_type;
     $config['wm_x_transp'] = $this->wm_x_transp;
     $config['wm_y_transp'] = $this->wm_y_transp;
     $config['wm_overlay_path'] = $this->wm_overlay_path;
     $config['wm_font_path'] = $this->wm_font_path;
     $config['wm_font_size'] = $this->wm_font_size;
     $config['wm_vrt_alignment'] = $this->wm_vrt_alignment;
     $config['wm_hor_alignment'] = $this->wm_hor_alignment;
     $config['wm_padding'] = $this->wm_padding;
     $config['wm_hor_offset'] = $this->wm_hor_offset;
     $config['wm_vrt_offset'] = $this->wm_vrt_offset;
     $config['wm_font_color'] = $this->wm_font_color;
     $config['wm_shadow_color'] = $this->wm_shadow_color;
     $config['wm_shadow_distance'] = $this->wm_shadow_distance;
     $config['wm_opacity'] = $this->wm_opacity;
     $img_lib = new Image_Lib($config);
     $img_lib->watermark();
 }