I am trying to create two thumbnails of an image uploaded by user. I repeated the code twice with a little change in configuration for second thumbnail but I get only the first thumbnail created and the second one does is not created. Here is the code:
//First Thumbnail
$conf['image_library'] = 'gd2';
$conf['source_image'] = "images/photos/123.jpg";
$conf['create_thumb'] = TRUE;
$conf['thumb_marker'] = "_1";
$conf['maintain_ratio'] = true;
$conf['width'] = 150;
$conf['height'] = 150;
$this->load->library('image_lib', $conf);
$this->image_lib->resize();
//Second smaller Thumbnail
$conf2['image_library'] = 'gd2';
$conf2['source_image'] = "images/photos/123.jpg";
$conf2['create_thumb'] = TRUE;
$conf2['thumb_marker'] = "_2";
$conf2['maintain_ratio'] = true;
$conf2['width'] = 50;
$conf2['height'] = 50;
$this->load->library('image_lib', $conf2);
$this->image_lib->resize();
For some reason the second part never works at all and the first part works well alone as well as with the second part. I think I should not load the library twice in same place. What can I do to fix this issue?
you need to clear the library in between, use this:
and if clearing and reloading doesn’t work, you can try just replacing the second library load with the initialize function which for some reason isn’t referred to in the ci_documentation: