code_junkie

Image Manipulation in CodeIgniter

Nov 12th, 2011
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. //Upload image first
  2. $config['upload_path'] = './uploads/';
  3. $config['allowed_types'] = 'gif|jpg|png|bmp';
  4.  
  5. $this->load->library('upload', $config);
  6. $this->upload->do_upload();
  7.  
  8. //Now fix the image
  9. $picloc = $this->upload->data();
  10. $picloc = $picloc['file_name'];
  11.  
  12. $thumbnail = "thumb_".$picloc;
  13.  
  14. $imagemanip['image_library'] = 'gd2';
  15. $imagemanip['source_image'] = './uploads/'.$picloc;
  16. $imagemanip['new_img'] = './uploads/'.$thumbnail;
  17. $imagemanip['maintain_ratio'] = TRUE;
  18. $imagemanip['width'] = 250;
  19. $imagemanip['height'] = 250;
  20.  
  21. $this->load->library('image_lib', $imagemanip);
  22.  
  23. $this->image_lib->resize();
  24.  
  25. $imagemanip['new_img'] = './uploads/'.$thumbnail;
  26.  
  27. $imagemanip['new_image'] = './uploads/'.$thumbnail;
Add Comment
Please, Sign In to add comment