I’m building an image gallery with Codeigniter everything is going good so far, but I had a quick question about image resizing.
Basically I upload the source image, and make create an id then store it in that path /uploads/$id/source.jpg. Then I try to create two new images of the source image, a thumbnail and a medium image with a watermark.
When using Codeigniter’s Image Manipulation Class can you set a file name and a upload path? And when you give it the source image does it modify the source image or does it make a copy?
public function generateThumnail($source, $screenid) {
$config['image_library'] = 'gd2';
$config['source_image'] = "$source";
$config['maintain_ratio'] = TRUE;
$config['width'] = 75;
$config['height'] = 50;
//Not sure how I set the upload path and file name.
$this->load->library('image_lib', $config);
$this->image_lib->resize();
//TODO: Code to be added later
$this->image_lib->clear();
}
The upload path and the file name aren’t include because I’m not sure how to add them. Is there any way to add them?
Yes, you can specify an upload path but by using the File Uploading Class, not the Image Manipulation Class.
http://codeigniter.com/user_guide/libraries/file_uploading.html
CodeIgniter will create a copy of the image if you tell it to.
http://codeigniter.com/user_guide/libraries/image_lib.html