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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:54:54+00:00 2026-05-17T16:54:54+00:00

Hey :) I want to resize an image when I address it in a

  • 0

Hey 🙂 I want to resize an image when I address it in a form(save to database). I dont think it will be a problem [pointing to the image etc, however the space I am going display the thumb in is 228 x 228. I know I can maintain the ratio and determine the size in the controller, yet how is it done on images that are frequently different sizes?

Is the best way to address this is to put pre-calculated values(make my own ratio) in my form so that the controller can use those values to determine max height and width? See code.

$config['image_library'] = 'gd2';
$config['source_image'] = '/path/to/image/mypic.jpg';
$config['create_thumb'] = TRUE;
$config['maintain_ratio'] = TRUE;
$config['width']     = 75; // use $this->input->post('width') instead??
$config['height']   = 50;  // use $this->input->post('height')

Or is there a way to tell the function no bigger than 228 and no wider than 228?

Thanks

  • 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-17T16:54:55+00:00Added an answer on May 17, 2026 at 4:54 pm

    I am not sure what you want exactly, but by using the following settings you can make sure either the width or the height of the image is 228px. If width > height, width will be 228px. And vice versa.

    $config['maintain_ratio'] = TRUE;
    $config['master_dim'] = 'auto' // auto is default, so you can leave this out
    $config['width'] = 228;
    $config['height'] = 228;
    

    master_dim

    Specifies what to use as the master
    axis when resizing or creating thumbs.
    For example, let’s say you want to
    resize an image to 100 X 75 pixels. If
    the source image size does not allow
    perfect resizing to those dimensions,
    this setting determines which axis
    should be used as the hard value.
    “auto” sets the axis automatically
    based on whether the image is taller
    then wider, or vice versa.

    If this is not what you mean, please add a bit more explanation.

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

Sidebar

Related Questions

Hey guys, quick question, all I want to do is resize an image to
Hey i dont know if that is possible but i want to set a
Hey guys I want a form to be submitted but it just won't work
Hey i want to know what will be output of following code:- main() {
Hey i want to display a Title and Image simultaneously on UIToolbar can any
Hey I want to reset the form but i don't know how. i mean
Hey Friends I want to make a form builder using Yii. For that I
hey i just want to gather the locations in google maps database which are
Hey there, i want to store some session info from a database query, upon
Hey guys. i want to be able to position my image background similar to

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.