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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:06:46+00:00 2026-06-01T18:06:46+00:00

I tried to find out, but I couldn’t. A image, for example, 241×76 has

  • 0

I tried to find out, but I couldn’t.

A image, for example, 241x76 has a total of 18,316 pixels (241 * 76).
The resize rule is, the amount of pixels cannot pass 10,000.
Then, how can I get the new size keeping the aspect ratio and getting less than 10,000 pixels?

  • 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-01T18:06:47+00:00Added an answer on June 1, 2026 at 6:06 pm

    Pseudocode:

    pixels = width * height
    if (pixels > 10000) then
      ratio = width / height
      scale = sqrt(pixels / 10000)
      height2 = floor(height / scale)
      width2 = floor(ratio * height / scale)
      ASSERT width2 * height2 <= 10000
    end if
    

    Remember to use floating-point math for all calculations involving ratio and scale when implementing.


    Python

    import math
    
    def capDimensions(width, height, maxPixels=10000):
      pixels = width * height
      if (pixels <= maxPixels):
        return (width, height)
    
      ratio = float(width) / height
      scale = math.sqrt(float(pixels) / maxPixels)
      height2 = int(float(height) / scale)
      width2 = int(ratio * height / scale)
      return (width2, height2)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I tried searching around, but I couldn't find anything that would help me out.
i tried to find it out with previous answers but i cannot do it
I tried reading the MSDN article on markup extensions, but I can’t find out
I tried looking but couldn't find any help. - (NSArray *)sushiTypes { return _sushiTypes;
probably basic, but couldn't find it in any other question. I tried: print [.join(seq)
Tried to find the answer, but still couldn't.. The table is as follows: id,
Ok I tried to google it but couldn't find a solution so I am
I have found many similar posts and even tried to find out how to
Ive tried searching for hours now and cannot find out why my code (aka,
I've tried my best to find out a solution with the many script questions

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.