0
我试过下面的代码在codeigniter中裁剪图像,但它没有工作。可能是我错过了分钟的事情。助手已加载,并且图像也存在 的代码是Codeigniter图像不裁剪
public function cropAndSave(){
$config['image_library'] = 'gd2';
$config['allowed_types'] = 'gif|jpg|png';
$config['source_image'] = './img-lab/xxx.jpg';
$config['create_thumb'] = true;
$config['maintain_ratio'] = false;
$config['width'] = 150;
$config['height'] = 190;
$config['new_image'] = "thumb_shahid.jpg";
$this->load->library('image_lib', $config);
$this->image_lib->resize();
echo '
<script>
window.parent.location="'. base_url().'"
</script>
';
}
无论错误显示 –
的某些其它代码/上下文会有帮助。例如,你在做什么!$ this-> image_lib-> crop()检查?我也想象一下,mypic.jpg不会是你图片的完整路径。 – simnom
您是否启用了完整的日志记录/调试功能?你还使用什么图形库?它没有被定义为'gd2'?等等;你需要安装该模块才能使用它,帮助者只是'帮助'使它更容易做到。 – Jakub