When sharing an image in an iPhone, we are given an opportunity to pick different sizes of an image – Small, Medium, Large, Original. And an opportunity of see the size in KB/MB along with each classification.
- Where does apple expose this code for users to leverage? I couldn’t spot it in my searches in iOS docs.
- What are some tested & tried frameworks/methods available on GitHub or elsewhere that can emulate this behavior?
EDITED:
I evaluated the solution posted by Brad Larson:
UIImage: Resize, then Crop
By confirming a decrease in size via the size measuring solution given below.
Together they are a good fit.
iOS is not open-source project. Apple releases only sample code which is used like tutorial sample project.
Here’s an article regarding calcutation of image file size.
This is very simple, though. Here’s the code:
Now you have your image size in bytes.
To convert it to kB divide it by 1024. If you want to get MB, divide by 1048576 (1024×1024).
Then you can display it to your user by formatting your message as following: