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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:53:52+00:00 2026-06-06T08:53:52+00:00

For any given file data size, I want to be able to resize (or

  • 0

For any given file data size, I want to be able to resize (or compress) a UIImage to fit within that data limit. This question is NOT about how to resize, or how to check file sizes… it is about an algorithm to getting this in a performant way.

Searching here already, I found this thread which talks about stepping down the image jpeg quality in a linear, or binary algorithm. This isn’t very performant, taking dozens of seconds at best.

I am working on iOS so images can be close to 10MB (from iPhone 4S). My target, although variable, is currently 3145728 bytes.

I am currently using UIImageJPEGRepresentation to compress a little, but to get to my low target it appears I would have to lose much quality for such a large photo. Is there a relation between UIImage size and NSData size? Is there some function where I can say something like:

area * X = dataSize

…and solve for a scale factor so I can resize in one shot?

  • 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-06T08:53:54+00:00Added an answer on June 6, 2026 at 8:53 am

    One idea I just had after looking at the thread you linked to: compressing a 10MB image is going to be relatively slow. How about resizing to be much smaller (so that compression is much faster), then performing the compression algorithm (from the link). This can then be used as a guide to the size of compressing the 10MB image? The idea being that the compression ratio should be similar for the same image, independent of size.

    Let’s say 1000×1000 pixels compressed is 10MB, target size is 3MB.

    Then say smaller 100×100 pixels (for example), compressed with same quality, is C MB. Then perform the binary search alg on the 100×100 image until size = C * (3/10). Then use this compression quality for the 1000×1000 image to get ~3MB image.

    Note: I have no idea how well this will work – it’s just a suggestion. What size to pick (I’ve used 100×100) for the smaller-sized image is also just a guess and something would need to be experimented with.

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

Sidebar

Related Questions

I'm trying to compress any given string to a shorter version, copy paste-able compressed
Please any one give me the suggestion for this. I'm having the Xerces-J-source.zip file
Can anyone give me any pointers. I have a text file that contains dates
For any given type i want to know its default value. In C#, there
i have a function that removes special characters from any given value, but my
I have a feeling this will be a quick fix, given that I started
My ini file does not have any section. It has following data com.ibm.rcp.toolbox.admin/toolboxvisibleChild=false com.ibm.collaboration.realtime.community/defaultAuthType=ST-DOMINO-SSO
For any given NSManagedObject, is there any method to return a set or array
I'm capturing a click on any given LI in: <ul> <li class=opt>Text 1</li> <li
When writing PHP code for any given project, do you find you can write

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.