Codeigniter 上傳縮圖 檔案沒出來但處理為 TRUE
$CI->load->library('image_lib',$img_resize_config);
照上面寫的話,Codeigniter 縮圖只會處理一次
要處理多張的話要拆開寫如下
$CI->load->library('image_lib');
$CI->load->initialize($img_resize_config);
但是我不管怎麼試就是縮圖出不來,而且
$CI->image_lib->resize();
一直都是正確的 TURE 值
後來才發現問題在第二行,改成如下搞定
$CI->image_lib->initialize($img_resize_config);
完整的縮圖 helper function 如下
function thumbMaker($data = array()){
$CI =& get_instance();
$img_resize_config['image_library'] = 'gd2';
$img_resize_config['source_image'] = $data['upload_data']['full_path'];
$img_resize_config['new_image'] = './pimage/1111'.'002.jpg';
$img_resize_config['create_thumb'] = TRUE;
$img_resize_config['maintain_ratio'] = TRUE;
$img_resize_config['width'] = 100;
$img_resize_config['height'] = 100;
$CI->load->library("image_lib");
$CI->image_lib->initialize($img_resize_config);
$CI->image_lib->resize();
$CI->image_lib->clear();
}
照上面寫的話,Codeigniter 縮圖只會處理一次
要處理多張的話要拆開寫如下
$CI->load->library('image_lib');
$CI->load->initialize($img_resize_config);
但是我不管怎麼試就是縮圖出不來,而且
$CI->image_lib->resize();
一直都是正確的 TURE 值
後來才發現問題在第二行,改成如下搞定
$CI->image_lib->initialize($img_resize_config);
完整的縮圖 helper function 如下
function thumbMaker($data = array()){
$CI =& get_instance();
$img_resize_config['image_library'] = 'gd2';
$img_resize_config['source_image'] = $data['upload_data']['full_path'];
$img_resize_config['new_image'] = './pimage/1111'.'002.jpg';
$img_resize_config['create_thumb'] = TRUE;
$img_resize_config['maintain_ratio'] = TRUE;
$img_resize_config['width'] = 100;
$img_resize_config['height'] = 100;
$CI->load->library("image_lib");
$CI->image_lib->initialize($img_resize_config);
$CI->image_lib->resize();
$CI->image_lib->clear();
}
Comments
Post a Comment