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

  • Home
  • SEARCH
  • 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 800049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:13:48+00:00 2026-05-14T23:13:48+00:00

For so many time, I have encountered problems with managing image having abnormally long

  • 0

For so many time, I have encountered problems with managing image having abnormally long height or width.

If I fixed their height and widht, they will appear streched?

If I fixed their width, and if the height of the image is very long then also it will mess up the overall website.

If I fixed their height, and if the width of the image is very long then also it will mess up the overall website.

The images I save in the local drive are saved maintaining the ratio?
Let say user decides to upload image 1(height)*32(width).
When he uploads this image, the script is made to resize the user uploaded image to height:1000px(just an example)

So the resulting image in 1000px(height)*32000(widht), you see now the image is abnormally large.

Now while displaying this image in a box of 1000px * 1000px, what is the best way to display this image?

  • 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-14T23:13:49+00:00Added an answer on May 14, 2026 at 11:13 pm

    If you’re trying to resize the 32×1 image so it fits within a 1000×1000 box, you shouldn’t be resizing the height to be 1000. Instead, you should resize the width to 1000 and the height to 1000/32.

    Some example code could be:

    define(MAX_WIDTH, 1000);
    define(MAX_HEIGHT, 1000);
    
    if ($cur_width / MAX_WIDTH > $cur_height / MAX_HEIGHT)
    {
       $new_width = MAX_WIDTH;
       $new_height = (int) ($cur_height * MAX_WIDTH / $cur_width);
    }
    else
    {
       $new_width = (int) ($cur_width * MAX_HEIGHT / $cur_height);
       $new_height = MAX_HEIGHT;
    }
    

    This checks which of the dimensions is “bigger” relative to the dimensions of the box and sets $new_width and $new_height appropriately. Make sure to handle weird cases where one of the dimensions gets rounded down to 0 (ie. a 10000×1 image would probably end up as 1000×0).

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

Sidebar

Related Questions

I have a asp.net page with .net controls. For a long time, many years,
I have an MDI parent form that creates many MDI children at run time.
While there are many guides for Browser Helper Objects, i have a hard time
I have installed the plugin many times before, but this time I keep getting
This may be the most obscure bug I have yet encountered in many years
Well like many other I encountered some problems while uploading my binary to appstore.
Long-time follower, thanks so much for all your help over the years! I have
I have encountered many half-solutions to the task of returning XML in ASP.NET. I
I've encountered some problems with MongoID. I have three models: require 'mongoid' class Configuration
i have many time series, each one representing a plant species. I think there

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.