Image library: resizing two or more images - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Image library: resizing two or more images (/showthread.php?tid=25025) |
Image library: resizing two or more images - El Forum - 11-27-2009 [eluser]tokyotech[/eluser] I want to create two thumbnails from the same source image. The following code only makes my first thumbnail, but will not create the second one. Why is that? Is it because the config array is passed into the constructor and an object cannot be instantiated twice? Code: $config['image_library'] = 'gd2'; Image library: resizing two or more images - El Forum - 11-28-2009 [eluser]markup2go[/eluser] This may help: Code: $this->image_lib->clear() "The clear function resets all of the values used when processing an image. You will want to call this if you are processing images in a loop." - User guide Image library: resizing two or more images - El Forum - 11-28-2009 [eluser]nkm82[/eluser] Also you should unset the first config array after the first resize (or name each one diferently). Code: $config['master_dim'] = 'width'; OR Code: $large_config = array(); Image library: resizing two or more images - El Forum - 11-28-2009 [eluser]tokyotech[/eluser] markup2go, My new code just has one line extra (the clear call), but it still doesn't work. I also tried printing out errors, but none were reported. Code: $config['image_library'] = 'gd2'; nkm82, I would like to reuse the same array because most of the info remains the same. The only differences are filename and size. Image library: resizing two or more images - El Forum - 11-28-2009 [eluser]Aken[/eluser] Without specific errors it's hard to help much. But I can tell you that the second time you want to use the library, don't load it over again, just reinitialize it. Instead of Code: $this->load->library('image_lib', $config); Code: $this->image_lib->initialize($config); Image library: resizing two or more images - El Forum - 11-28-2009 [eluser]demogar[/eluser] I would use a function for it so I can reuse code and it would be just simplier to modify. Code: function something(){ Cheers Image library: resizing two or more images - El Forum - 11-28-2009 [eluser]tokyotech[/eluser] Yes! It works now. Thanks everyone. Image library: resizing two or more images - El Forum - 04-09-2010 [eluser]Marc Arbour[/eluser] I am in a dead end with this... I slightly adapted the above code. Here is what I use in my controler: Code: in my calling function: Only the 1st thumb is created. Wheter I change them around one another, the small or the large one gets created. it seems the $this->image_lib->clear(); is not working properly. Any ideas? (using latest CI version) Duke Image library: resizing two or more images - El Forum - 04-09-2010 [eluser]Marc Arbour[/eluser] Hi. I solved it with this code: http://ellislab.com/forums/viewthread/115907/ |