IOS: the fileSize of the selected image is bigger then the original one [🐛]
See original GitHub issueDescription
Continues to happen in version 4.
After selecting an image using the library, the asset object contains a fileSize that is different (bigger) from the original image size. NO maxWidth and NO maxHeight were applied. quality: 1.
This issue has been reported a couple of times in the past #1419, #514 but these reports have been closed and the issue continues to happen.
How to repeat issue and example
- Note the image size from the photos app on iOS
- Select that image using this library (NO maxWidth, NO maxHeight, quality: 1) and compare the sizes (sometimes the image is 2 or even 3 times bigger in size)
launchImageLibrary({
includeBase64: false,
mediaType: 'photo',
quality: 1,
selectionLimit: 1,
}, (response) => {
const { assets } = response;
if (Array.isArray(assets) && assets.length > 0) {
const [{ fileSize }] = assets;
console.log(fileSize / 1024 / 1024);
console.log(fileSize / 1000 / 1000);
}
})
Expected: 1.9 Result:
6.392001152038574
6.7024989999999995
Solution
What needs to be done to address this issue?
Make sure that the fileSize of the selected image is the same as the original one when no maxWidth and no maxHeight options provided and quality option is set at 1.
Additional Information
Tested on:
- Image Picker version: v4.1.1 and v4.6.0
- React Native version: v0.63.3
- Platform: iOS (iPhone 11 - real device)
- Development Operating System: MacOS v12.0 and v12.1
- Dev tools:
- Xcode v13.1 and v13.2
- iOS v14.4, v15.1 and v15.2
- node v14.17.4
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
How to get image file size in Swift? - ios - Stack Overflow
On adding image in your Xcode the size of the image will remain same in project directory. But you get it from its...
Read more >In Swift, how to reduce an image f… | Apple Developer Forums
In Swift, how to reduce an image file size to a specific size? ... After taking/importing photo to app, automatically reduce the size...
Read more >File in Photos app and Files app shows different size when ...
Now, the size of the file(some name like IMG_0567.MOV ) shown in the Files app on iPhone is different from the file size...
Read more >5 Ways to Find the File Size of an iOS Photo - wikiHow
1. Open the Photos app. It has an icon with a white background and a multicolored flower in it. 2. Open the photo...
Read more >How to Resize and Reduce Photo File Size on iPhone or iPad ...
Do you want to crop, resize and reduce the photo file size that you took from your iPhone ? You can compress the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Indeed I came up on this myself too. On Android the filesize is reduced just fine but on iOS I once noticed an image from 1.7MB to become 3MB.
In addition if the above temp image size is still larger when transferring over the network, it’s likely because the
RCTNetworking.mm
is still usingRCTImageLoader.mm
to convert the image uri to binary data.you can customize a new handler to the
RCTNetworking.mm
(put these two files in your project)