![]() |
[SOLVED] Problems using image lib in a loop - 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: [SOLVED] Problems using image lib in a loop (/showthread.php?tid=35793) |
[SOLVED] Problems using image lib in a loop - El Forum - 11-11-2010 [eluser]Mr. Pickle[/eluser] I'm having problems using the image_lib in a loop. Description: I have a folder with several image files. I loop all the image files within a folder to copy them (with new dimensions) to a different directory. Therefor I use the image_lib with which you have to set the settings (such as source file, dimensions and destination file) in a config array and pass them to the image lib. This is my code for that part: Code: $config['image_library']= 'gd2'; Next thing is that I do the resize action: Code: $this->image_lib->resize(); After this I clear the image_lib: Code: $this->image_lib->clear(); My problem The image lib is still using the config from the first loop as I only get the first image (name) with the last image content in my destination folder. [SOLVED] Problems using image lib in a loop - El Forum - 11-11-2010 [eluser]Mr. Pickle[/eluser] Found the solution, I had to (re)initialize the image_lib: First, just call the image_lib without config outside the loop. After this within the loop I set the settings config for the loop and have the image_lib first cleared and then re-initialized with the settings for that loop. So outside the loop: Code: $this->load->library('image_lib'); And within the loop: Code: // Set all the configs [SOLVED] Problems using image lib in a loop - El Forum - 03-08-2011 [eluser]OttoVanzig[/eluser] many thanks great it works now, was just loosing my residual hears on this issue ! |