脚本宝典收集整理的这篇文章主要介绍了php – codeigniter调整图像大小并创建缩略图,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
create_thumb FALSE TRUE/FALSE (boolean) Tells the image PRocessing function to create a thumb. R thumb_marker _thumb None SPEcifies the thumbnail indicator. IT will be inserted just before the file extension,so mypic.jpg would become mypic_thumb.jpg R
所以这是我的代码
$config_manip = array( 'image_library' => 'GD2','source_image' => "./uploads/avatar/tmp/{$this->input->post('new_val')}",'new_image' => "./uploads/avatar/{$this->input->post('new_val')}",'maintain_ratio'=> TRUE,'create_thumb' => TRUE,'thumb_marker' => '_thumb','width' => 150,'height' => 150 ); $this->load->library('image_lib',$config_manip); $this->image_lib->resize();
我会假设此代码调整我的图像大小,并创建一个缩略图,但我只获得一个具有指定尺寸的图像和_tump后缀
我也尝试添加此代码手动创建第二个图像,但它仍然无法工作,我只得到一个图像
$this->image_lib->clear(); $config_manip['new_image'] = "./uploads/avatar/thumbnail_{$this->input->post('new_val')}"; $config_manip['width'] = 30 ; $config_manip['height'] = 30 ; $this->load->library('image_lib',$config_manip); $this->image_lib->resize();
public function do_resize() { $filename = $this->input->post('new_val'); $source_path = $_SERVER['DOCUMENT_ROOT'] . '/uploads/avatar/tmp/' . $filename; $target_path = $_SERVER['DOCUMENT_ROOT'] . '/uploads/avatar/'; $config_manip = array( 'image_library' => 'gd2','source_image' => $source_path,'new_image' => $target_path,'maintain_ratio' => TRUE,'create_thumb' => TRUE,'thumb_marker' => '_thumb','width' => 150,'height' => 150 ); $this->load->library('image_lib',$config_manip); if (!$this->image_lib->resize()) { echo $this->image_lib->display_errors(); } // clear // $this->image_lib->clear(); }
希望这对你有所帮助.谢谢!!
以上是脚本宝典为你收集整理的php – codeigniter调整图像大小并创建缩略图全部内容,希望文章能够帮你解决php – codeigniter调整图像大小并创建缩略图所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。