用户
 找回密码
 入住 CI 中国社区
搜索
查看: 4736|回复: 1
收起左侧

[已解决] 生成缩略图,Image_lib.php报错A non well formed numeric value encountered

[复制链接]
发表于 2011-5-20 12:47:15 | 显示全部楼层 |阅读模式
本帖最后由 melkor 于 2011-5-20 13:20 编辑

看论坛上有一篇帖子是关于多个缩略图生成的,直接用了那段代码,修改了一些。
PHP复制代码
if (!$this->upload->do_upload('goods_image')) {  // 图片上传失败
 
 
  $data['error'] = $this->upload->display_errors('<span class="show_error">', '</span>');
 
 
  $this->load->view('./manage/add_goods', $data);
 
} else {  // 图片上传成功
 
 
  $image_data = $this->upload->data();
 
 
  if($image_data['is_image'] == 1) {
 
 
    $configThumb = $this->aid->thumb_config('goods_images');
 
    $configThumb['source_image'] = $image_data['full_path']; //文件路径带文件名
 
    $this->image_lib->initialize($configThumb);
 
    $this->image_lib->resize();
 
 
    $configLarge = $this->aid->larger_config('goods_images');
 
    $configLarge['source_image'] = $image_data['full_path']; //文件路径带文件名
 
    $this->image_lib->initialize($configLarge);
 
    $this->image_lib->resize();
 
  }
 
 
  $goods_info = array(
 
  'goods_name' => $this->input->post('goods_name'),
 
  'goods_user_id' => $this->user_id,
 
  'goods_description' => $this->input->post('goods_description'),
 
  'goods_category_id' => $this->input->post('goods_category'),
 
  'goods_end_time' => $this->input->post('goods_end_time'),
 
  'goods_quantity' => $this->input->post('goods_quantity'),
 
  'goods_condition' => $this->input->post('goods_condition'),
 
  'goods_price_max' => $goods_price_max,
 
  'goods_price_min' => $goods_price_min,
 
  'goods_place' => $this->input->post('goods_place'),
 
  'goods_payment' => $this->input->post('goods_payment'),
 
  'goods_image' => $image_data['file_name']
 
  );
 
 
 
  $this->Goods_query->insert_goods($goods_info);
 
}
 
 
复制代码



运行的时候却报错了:

A PHP Error was encountered
Severity: Notice
Message: A non well formed numeric value encountered
Filename: libraries/Image_lib.php
Line Number: 514



A PHP Error was encountered
Severity: Notice
Message: A non well formed numeric value encountered
Filename: libraries/Image_lib.php
Line Number: 522



缩略图没有生成,为什么会这样呢?报错的部分看了下代码:
PHP复制代码
 
$dst_img = $create($this->width, $this->height);
 
复制代码

PHP复制代码
 
$copy($dst_img, $src_img, 0, 0, $this->x_axis, $this->y_axis, $this->width, $this->height, $this->orig_width, $this->orig_height);
 
复制代码



这种错误搜了一下,大部分都是日期时间函数的输入有问题。但是这两行的输入怎么也会这样?难道是高度宽度的数字格式不对?大概都是××px这样……这个错误会有什么影响?怎么去除?

发表于 2011-5-20 15:13:22 | 显示全部楼层
请仔细阅读手册 http://codeigniter.org.cn/user_guide/libraries/image_lib.html
你使用 resize() 但是并没有指定缩小的宽度和高度。

本版积分规则