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 8992075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:52:18+00:00 2026-06-15T22:52:18+00:00

Im having a problem with codeigniter image resize. I upload the file as a

  • 0

Im having a problem with codeigniter image resize. I upload the file as a zip file then unzip, after unzipping I scan the dir to look for a .jpg. if its a .jpg extension it needs to be resize. It works when the zip file has only one .jpg image but its not working when the zip file has 2 pr more .jpg image files.

It does scan all the jpg files problem is its not resizing.

I wanted to resize all the jpg files when I upload the zip file.

here is my code:

$images = scandir('uploads/new');
//print_r($images);
foreach($images as $image){
    $last = substr($image, -3);
    if($last == 'jpg'){
        $image_path = './uploads/new/'.$image;

        //$config['image_library'] = 'gd2';
        $config['source_image'] = $image_path;
        $config['maintain_ratio'] = TRUE;
        $config['width'] = 100;
        $config['height'] = 100;

        $this->load->library('image_lib', $config);

        $this->image_lib->resize(); 
    }
}       
  • 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-15T22:52:19+00:00Added an answer on June 15, 2026 at 10:52 pm

    You should use $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.

    $this->image_lib->clear();

    From : http://ellislab.com/codeigniter/user-guide/libraries/image_lib.html

    Also a hint:

    No need to use string functions to get your file extension. You can use something that’s actually designed for what you want: pathinfo():

    $ext = pathinfo($image, PATHINFO_EXTENSION);
    

    In your case :

    if(pathinfo($image, PATHINFO_EXTENSION) == 'jpg'){
    

    This way, if you would ever add an extension with more then 3 letters it would work 😉

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

Sidebar

Related Questions

I'm having a problem: I want to resize and watermark an image in CodeIgniter.
Having a problem with image manipulation in codeigniter - it bombs when I get
Im using jquerymobile together with codeigniter framework and I'm having a problem I have
im having problems starting a codeigniter project, the problem is that when i do
I am having a problem with running commands via cli doctrine-cli.php file. I am
I'm having problems with a photo upload system in Codeigniter. I'm uploading and resizing
Hello I just started CodeIgniter . I am having problem in loading view. My
I am having the following problem: Environment PHP, codeigniter framework with PDO. my code
I am having a weird issue with cookies in CodeIgniter. The problem is I
I'm having a problem uploading files in CodeIgniter. This is my autoload: $autoload['helper'] =

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.