CodeIgniter中的图像操作 [英] Image Manipulation in CodeIgniter

查看:64
本文介绍了CodeIgniter中的图像操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用CodeIgniter 1.7处理图片时遇到了一些问题。使用以下代码,图像正确上传。唉,而不是一个新的图像,然后修改;则修改现有图像。任何帮助?

I am having some trouble manipulating images using CodeIgniter 1.7. With the following code, the image is uploaded correctly. Alas, instead of a new image being made, and then modified; the existing image is modified. Any help?

//Upload image first
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png|bmp';

$this->load->library('upload', $config);        
$this->upload->do_upload();

//Now fix the image
$picloc = $this->upload->data();
$picloc = $picloc['file_name'];

$thumbnail = "thumb_".$picloc;

$imagemanip['image_library'] = 'gd2';
$imagemanip['source_image'] = './uploads/'.$picloc;
$imagemanip['new_img'] = './uploads/'.$thumbnail;
$imagemanip['maintain_ratio'] = TRUE;
$imagemanip['width'] = 250;
$imagemanip['height'] = 250;

$this->load->library('image_lib', $imagemanip);

$this->image_lib->resize();


推荐答案

问题很简单,行:

$imagemanip['new_img'] = './uploads/'.$thumbnail;

索引应该是new_image,而不是new_img / p>

The the index should be "new_image", not "new_img", so the line becomes..

$imagemanip['new_image'] = './uploads/'.$thumbnail;

这篇关于CodeIgniter中的图像操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆