Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8478847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:51:37+00:00 2026-06-10T18:51:37+00:00

I am new to Codeigniter. This is what I want to do: User uploads

  • 0

I am new to Codeigniter. This is what I want to do:

  1. User uploads a profile picture.
  2. I resize the original image to several sizes, e.g. 400×300, 200×200, and 32×32.

But what I when I upload the image is that it’s re-sized successfully only for one dimension, 400×300.

Here is my code:

 $config['image_library']   = 'gd2';
 $config['source_image']    = '/path/to/image/mypic.jpg';
 $config['create_thumb']    = TRUE;
 $config['maintain_ratio']  = TRUE;
 $config['width']           = 400;
 $config['height']          = 300;
 $config['new_image']   = 400x300image;
 $this->load->library('image_lib', $config); 
 $this->image_lib->resize();
 $this->image_lib->clear()

 $config['image_library']   = 'gd2';
 $config['source_image']    = '/path/to/image/mypic.jpg';
 $config['create_thumb']    = TRUE;
 $config['maintain_ratio']  = TRUE;
 $config['width']           = 200;
 $config['height']          = 200;
 $config['new_image']   = 200x200image;
 $this->load->library('image_lib', $config); 
 $this->image_lib->resize();
 $this->image_lib->clear()

 $config['image_library']   = 'gd2';
 $config['source_image']    = '/path/to/image/mypic.jpg';
 $config['create_thumb']    = TRUE;
 $config['maintain_ratio']  = TRUE;
 $config['width']           = 32;
 $config['height']          = 32;
 $config['new_image']   = 32x32image;
 $this->load->library('image_lib', $config); 
 $this->image_lib->resize();
 $this->image_lib->clear();

I tried using different config names like $config2 and $config3 but I did’t get the output.

Please help me to solve the issue.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T18:51:39+00:00Added an answer on June 10, 2026 at 6:51 pm

    I have a similar function built into one of my CI apps. In my case, I needed the config files in another function, so I built separate versions.

    Don’t load the library multiple times. Once is fine. Just reinitialize the the library with your new config each time.

     $this->load->library('image_lib');
    
     /* First size */
     $configSize1['image_library']   = 'gd2';
     $configSize1['source_image']    = '/path/to/image/mypic.jpg';
     $configSize1['create_thumb']    = TRUE;
     $configSize1['maintain_ratio']  = TRUE;
     $configSize1['width']           = 400;
     $configSize1['height']          = 300;
     $configSize1['new_image']   = '400x300image';
    
     $this->image_lib->initialize($configSize1);
     $this->image_lib->resize();
     $this->image_lib->clear();
    
     /* Second size */    
     $configSize2['image_library']   = 'gd2';
     $configSize2['source_image']    = '/path/to/image/mypic.jpg';
     $configSize2['create_thumb']    = TRUE;
     $configSize2['maintain_ratio']  = TRUE;
     $configSize2['width']           = 200;
     $configSize2['height']          = 200;
     $configSize2['new_image']   = '200x200image';
    
     $this->image_lib->initialize($configSize2);
     $this->image_lib->resize();
     $this->image_lib->clear();
    

    And so on. I suppose, for memory’s sake, you could unset and reset the config file, as was suggested above, but if you plan on using the image resizing in separate controller methods as I did, I found it helpful to save those separately.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to this codeigniter. I am building a application where in user
I'm new to codeigniter this is my case: I have a homepage with a
I am planning a new website with codeigniter using wordpress. this site will contain
I am fairly new to PHP and Codeigniter so im sure this will be
I'm new in CodeIgniter and read user guide from website. Using pagination class, pagination
I am new in codeigniter, even in PHP. I want to upload a zipped
I want to parse this RSS (from a bit.ly user stream) to grab all
Hello I am new to codeigniter. I am learning this framework by developing a
I had my users profile at www.domain.com/user/username and moved it at www.domain.com/username but this
I am new to codeigniter. I want to know use of $CI =& get_instance();

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.