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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:13:06+00:00 2026-06-04T14:13:06+00:00

I am doing little work for my website and I would like to auto-resize

  • 0

I am doing little work for my website and I would like to auto-resize my images.. But not only auto-resize, but keep them proportional, even if I resize their width or height. I want to add additional white borders to compensate for new space.

I have never done any image work in the past, how should I approach this?

  • 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-04T14:13:08+00:00Added an answer on June 4, 2026 at 2:13 pm

    Calculate the height as if the width would fit, then check that against the height of the container. If it’s higher, then calculate the width to make the height fit:

    newHeight = oldHeight * containerWidth / oldWidth;
    if (newHeight <= containerHeight) {
      newWidth = containerWidth;
    } else {
      newWidth = oldWidth * containerHeight / oldHeight;
      newHeight = containerHeight;
    }
    

    Now you can calculate where to place the image to center it:

    x = (containerWidth - newWidth) / 2;
    y = (containerHeight - newHeight) / 2;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been doing a little JavaScript (well, more like jQuery) for a while now
I've started doing a little freelance web work and I've got to build a
I've been working on a website for a little while now, doing most of
I've been trying to get this little project I'm doing finished, but for some
I helped a friend out by doing a little web work for him. Part
I'm doing a little bit of work on a horrid piece of software built
I have an HTML app, not a native app. It's like a website, and
I have been doing a little work with regex over the past week and
How are you doing? am having a little difficulty writing my first HTML website!
I am just doing a little work this morning making some static libraries. Why

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.