Upload image --> resize and create thumb |
[eluser]hsl[/eluser]
Hello, I'm trying to upload an image. So far it works. Now with the uploaded image i want to resize it to a new directory and make a thumb at the same time. So this is what i do: Code: public function img_resize($upload,$post) The second function doesn't work and there doesn't seem to be a way to do it in one image resize action. This is what is in my controller: Code: $config_upload['upload_path'] = './assets/temp/'; How would you guys solve this? Regards, HSL
[eluser]Sumon[/eluser]
Try by add Code: $this->image_lib->clear(); Code: $this->make_thumb($newpath); if you still getting same problem then try with Code: unset($config);
[eluser]hsl[/eluser]
Thx! But it still doesn't work, with both options I get this error: Code: Your server does not support the GD function required to process this type of image. any other ideas?
[eluser]manilodisan[/eluser]
Since I started using verot's class I never looked back... . I can't remember very well but I had problems with CI's integrated upload class at that time and I started looking for a serious class to perform uploads and image manipulation tasks.
[eluser]Sumon[/eluser]
Do your server have GD library? Code: echo phpinfo(); // now see whether GD is installed in your server or not.
[eluser]hsl[/eluser]
[quote author="manilodisan" date="1221970290"]Since I started using verot's class I never looked back... . I can't remember very well but I had problems with CI's integrated upload class at that time and I started looking for a serious class to perform uploads and image manipulation tasks.[/quote] Mhmmm,.. i'm not really planning to use an extern class within a CI project. [quote author="Sumon" date="1221996672"]Do your server have GD library? Code: echo phpinfo(); // now see whether GD is installed in your server or not. Yes, It has, the first action: resizing and copying work fine. It's the second function create_thumb() that's giving the error.
[eluser]hsl[/eluser]
the first function is now this: Code: public function img_resize($upload,$post) Code: public function make_thumb($path)
[eluser]hsl[/eluser]
fixed it,.. now I load the library only once, and initialize it with the new config in each function. Code: public function img_resize($upload,$post)
[eluser]vvva_avvv[/eluser]
Somebody help me :cheese: I try to upload. It work but I can't resize my image. I guess my source_image not detect because if I close this code $config['source-image'], there isn't influence. Please help me how to resize. This the code : function do_upload() { $this->load->library('Image_lib'); $config['allowed_types'] = 'gif|jpg|png|jpeg'; $config['upload_path'] = realpath(APPPATH.'../uploads/avatar'); $config['overwrite'] = TRUE; $config['max_size'] = '200'; $config['max_width'] = '500'; $config['max_height'] = '500'; $this->load->library('upload', $config); $this->upload->do_upload('file'); $image = $this->upload->data(); $config['image_library'] = 'gd'; $config['source_image'] = realpath(APPPATH.'../uploads/avatar').$image['file_name']; $config['new_image'] = realpath(APPPATH.'../uploads/avatar').'/after'.$image['file_name']; $config['create_thumb'] = TRUE; $config['maintain_ratio'] = TRUE; $config['width'] = 75; $config['height']=75; $this->upload->initialize($config);//if we need $this->load->library('image_lib', $config); if(!$this->image_lib->resize()) {echo $this->image_lib->display_errors(); } else { $this->load->helper('url'); $data['file']=$image['file_name']; $this->load->view('sss', $data); } } thank for your help ^^
[eluser]Samuel Martins[/eluser]
[quote author="hsl" date="1222026819"]fixed it,.. now I load the library only once, and initialize it with the new config in each function. Code: public function img_resize($upload,$post) I am doing exactly the same that you with a diferent directories, but only do img_resize() and when is to do the thumb i receive this message error Quote:Unable to save the image. Please make sure the image and file directory are writable. My directory is OK with the permissions.. any help please. |
Welcome Guest, Not a member yet? Register Sign In |