dsxml2169 2015-01-31 08:16 采纳率: 0%
浏览 38

如何调整文件中的图像获取内容

I'm using codeigniter and i want to resize image from user that upload via url.

Here is my code:

            //upload via url
            $url = $this->input->post('photo');
            /* Extract the filename */
            $filename = substr($url, strrpos($url, '/') + 1);
            /* Save file wherever you want */
            file_put_contents('myuploads/'.$filename, file_get_contents($url));
            //resize start
            $config['image_library'] = 'gd2';
            $config['source_image']  = $filename;
            $config['overwrite']     = TRUE;
            $config['width'] = 59;
            $config['height'] = 90;
            $this->load->library('image_lib', $config);
            $this->image_lib->initialize($config);
            $this->image_lib->resize();
            $data=array(
                'username'=>$this->input->post('username'),
                'deskrip'=>$this->input->post('deskrip'),
                'photo'=>$filename
              );
            $this->db->where('id',$id);
            $outp = $this->db->update('user',$data);

Upload is working but the problem is the image won't resize into 59x90 and still in original size.

Any answer?

Many thanks..

  • 写回答

2条回答 默认 最新

  • duanlieshuang5330 2015-01-31 10:14
    关注

    resize() method is working or not you can see error by :

        if ( ! $this->image_lib->resize())
    {
        echo $this->image_lib->display_errors();
    }
    

    see Documentation There is a nice tutorial of image Manipulation ,from tutsplus

    Hope this help you.

    Thanks

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度