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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:40:14+00:00 2026-05-23T13:40:14+00:00

I am using the image library in Codeigniter to resize my image. I notice

  • 0

I am using the image library in Codeigniter to resize my image. I notice that CI only resizes the image to fit inside the specified dimensions: A 50px by 50px image resized to fit a 30px by 20px box will be resized to 20px by 20px and leaves a black area for the empty space.

What I want is to resize such that the resize image fills the entire 30px by 30px space with the excess portion being cropped out.

Is this possible in Codeigniter?

  • 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-05-23T13:40:15+00:00Added an answer on May 23, 2026 at 1:40 pm

    I think you’ll need to resize the image first, choosing either width or height as the “master” dimension, then crop it.

    I haven’t tested this code, but give it a shot. If nothing else, it should give you the idea.

    $config['source_image'] = '/path/to/image/mypic.jpg';
    
    $config['width'] = 30;
    $config['height'] = 0; // No restraint on height
    $this->load->library('image_lib', $config);
    $this->image_lib->resize();
    
    $config['x_axis'] = 30; // Same width as before
    $config['y_axis'] = 20; // Crop to height
    $this->image_lib->initialize($config);
    $this->image_lib->crop();
    

    You may want to try to center the crop dimensions instead. Whichever way you choose to do it, the image needs to be cropped at some point.

    I should note that I’m not sure if $config['height'] = 0 is the right way to ignore height, it might have to be FALSE, a really high number, or removed altogether (haven’t worked with the CI image lib in a while).

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

Sidebar

Related Questions

I'm using Codeigniter's image manipulation library to re-size an uploaded image to three sizes,
I'm using an image manipulation library that throws an exception when I attempt to
sigh I'm sorry to say that I'm using Intel IPL (Image Processing Library) in
I find the codeigniter image library is very useful, lot of features there. Only
It's ok to upload image in file using codeigniter upload library with this example.
I am using the GD Library to add text to the PNG Image of
I'm creating an dynamic image, which creates headers on my page using PHPs GD-library.
I am trying to create a sortable image matrix, 5x5 using scriptaculous javascript library
I'm using an image component that has a FromBinary method. Wondering how do I
My application is using an image processing library to handle a long running task.

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.