Part of the EllisLab Network
   
 
Image library and resizing multiple images - a bug (small one)
Posted: 01 June 2007 04:32 AM   [ Ignore ]  
Summer Student
Total Posts:  28
Joined  11-29-2006

If you load the library and then try to resize more than one image with multiple resize calls, it’ll resize the first one but fail on the others.  This is because it does not “clear” the properties associated with the Image_lib class before doing a new resize call.

Hence, the workaround is the following:

$config['source_image'] = $source_image;
        
$config['new_image'] = $new_image;            
        
$config['width'] = $width;
        
$config['height'] = $height;            
        
$this->load->library('image_lib');
        
$this->image_lib->clear();
        
$this->image_lib->initialize($config);

CLEAR is not documented in the user guide but it’s a function that can and should be used before recycling the library for another image manipulation.  First CLEAR and then INITIALIZE with the new config parameters.

Profile
 
 
Posted: 01 June 2007 09:39 AM   [ Ignore ]   [ # 1 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  722
Joined  08-06-2006

Hi niyogi,

Thanks for pointing out errors in the manual! I think the manual is one of the strongest points of CI and I (for one among many) would like to see it stay in tip tip shape.

Would you post this to the BugTracker so that it can be fixed with the other recent submissions I made? (see the CI home page for the link) There is a category just for Manual “bugs” like this one, and also typos.

Cheers!

Profile
 
 
Posted: 01 June 2007 09:51 AM   [ Ignore ]   [ # 2 ]  
Summer Student
Total Posts:  28
Joined  11-29-2006

Already in there - thanks for the appreciation.  CodeIgniter does have some solid docs but there are many holes that, with user submission, would make it even better.  I think it should follow the format of php.net documentation - user submissions to compliment the core.

Profile
 
 
Posted: 24 July 2007 11:20 AM   [ Ignore ]   [ # 3 ]  
Grad Student
Avatar
Rank
Total Posts:  66
Joined  02-05-2007

It works flaweless grin
Thanks

Profile
 
 
Posted: 25 November 2007 11:32 PM   [ Ignore ]   [ # 4 ]  
Summer Student
Total Posts:  12
Joined  06-13-2007

Thanks for this. Encountered this and seeing as merely initializing it didn’t do any good, clearing it did the trick.

niyogi - 01 June 2007 04:32 AM

$this->image_lib->clear();
$this->image_lib->initialize($config);

CLEAR is not documented in the user guide but it’s a function that can and should be used before recycling the library for another image manipulation.  First CLEAR and then INITIALIZE with the new config parameters.

Profile
 
 
Posted: 05 December 2007 06:41 AM   [ Ignore ]   [ # 5 ]  
Summer Student
Total Posts:  28
Joined  11-26-2007

Just to say thanks for your help, works great.

Profile
 
 
Posted: 10 July 2008 12:00 PM   [ Ignore ]   [ # 6 ]  
Summer Student
Total Posts:  9
Joined  02-20-2008

Another big thanks for the assistance, I saw the CLEAR portion and the INITIALIZE portion in the documentation but didn’t think to put them together to process additional images.

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 719, on June 06, 2008 10:16 AM
Total Registered Members: 64455 Total Logged-in Users: 22
Total Topics: 80961 Total Anonymous Users: 0
Total Replies: 435697 Total Guests: 179
Total Posts: 516658    
Members ( View Memberlist )