Welcome Guest, Not a member yet? Register   Sign In
Help with thumbnail creation using image manipulation class
#1

[eluser]Dandy_andy[/eluser]
I am a bit stuck with image manipulation and thumbnail generation. I have a controller that process a file uploaded and is supposed to do the following:-

1. SAVE THE IMAGE TO A DIRECTORY AFTER RENAMING IT ($string)
2. RESIZE THE IMAGE
3. CREATE A THUMBNAIL OF THE RESIZED IMAGE SO THAT TWO IMAGES SHOULD EXIST IN THE DIRECTORY.

The script below works as far as creating the directory and the new re-sized image, but I can't seem to then create a thumbnail of the resized image. Any ideas?

Code:
//upload photo file
public function upload_file() {

  $this->load->model('image_file');
  $string = $this->image_file->string_generate();
  $set_image_path = $this->image_file->set_image_path($string);
  
  $config['upload_path'] = $set_image_path;
  $config['allowed_types'] = 'gif|jpg|jpeg|png';
  $config['max_size'] = '4000';
  $config['max_width'] = '6000';
  $config['max_height'] = '4000';
  $config['file_name'] = $string;
  $this->load->library('upload', $config);
  
  //write the data to the photo db
  $mem_id = $this->session->userdata('mem_id');
  $this->image_file->write_imagedata($mem_id, $string, $set_image_path);
  
  //create the directory
  mkdir($set_image_path, 0644, true);
  
  //do upload & process image (rezize and rename)
  $this->upload->do_upload('userphoto');
  $results = $this->upload->data();
  $config['image_library'] = 'gd2';
  $config['source_image'] = $set_image_path.$string;
  $config['create_thumb'] = FALSE;
  $config['maintain_ratio'] = TRUE;
  $config['quality'] = 50;
  $config['width'] = 800;
  $config['height'] = 600;
  $this->load->library('image_lib', $config);
  $this->image_lib->resize();
  $this->image_lib->clear();
  
  //create thumbnail
  $config['image_library'] = 'gd2';
  $config['source_image'] = $set_image_path.$string;
  $config['create_thumb'] = TRUE;
  $config['maintain_ratio'] = TRUE;
  $config['quality'] = 50;
  $config['width'] = 200;
  $config['height'] = 150;
  $this->image_lib->resize();

It seems to get as far as the //create thumbnail but doesn't process anything beyond this.


Messages In This Thread
Help with thumbnail creation using image manipulation class - by El Forum - 06-14-2012, 04:18 AM



Theme © iAndrew 2016 - Forum software by © MyBB