-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: the fileSize of the selected image is bigger than the origin one in ios #2006
fix: the fileSize of the selected image is bigger than the origin one in ios #2006
Conversation
cc @Johan-dutoit hello! I hope we would be able to get this PR merged as we believe it resolves the problem with the increased image size on iOS. Thank you for leaving a review here! |
## [4.8.5](v4.8.4...v4.8.5) (2022-08-08) ### Bug Fixes * the fileSize of the selected image is bigger than the origin one in IOS ([#2006](#2006)) ([6157225](6157225))
🎉 This PR is included in version 4.8.5 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Thank @Johan-dutoit for a quick help 🙌 |
## [4.8.5](react-native-image-picker/react-native-image-picker@v4.8.4...v4.8.5) (2022-08-08) ### Bug Fixes * the fileSize of the selected image is bigger than the origin one in IOS ([#2006](react-native-image-picker/react-native-image-picker#2006)) ([3d6c56f](react-native-image-picker/react-native-image-picker@3d6c56f))
Can we revert this? the returned data size is not correct if the quality is |
@s77rt can you elaborate on why double the size of original file is an expected output? I think the image picked should have the same size as the image in gallery |
@mountiny I think it only seems double because apple stores images in heic format and the conversion from heic to jpeg is not efficient thus the large size. |
float quality = [self.options[@"quality"] floatValue]; | ||
if (![image isEqual:newImage] || (quality >= 0 && quality < 1)) { | ||
if ([fileType isEqualToString:@"jpg"]) { | ||
data = UIImageJPEGRepresentation(newImage, quality); | ||
} else if ([fileType isEqualToString:@"png"]) { | ||
data = UIImagePNGRepresentation(newImage); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Johan-dutoit Sorry for the ping.
Can you take a quick look at this, I think we should revert this part (get ride of the first condition)
Still investigating, this PR introduced the issue but the root cause exists long before...
Details posted on #2052
main
branch, NOT a "stable" branch.Motivation (required)
This PR fixes a bug described in issue 1894.
the binary data returned by
UIImageJPEGRepresentation
andUIImagePNGRepresentation
is much larger thanthe original file.
this PR will use the original data first if user doesn't pass
maxWidth
,maxHeight
andquality
Test Plan (required)
prepare a image:
Team
andBundle Identifier
may need to be configured first).Select Image
to select the above imagefileSize
in the screen with the value in thePhoto
( or usels -l
to check the saved image size)Take image
and compare the two values againIn addition,
there is an issue in the
react-native
library when used for upload,I've provided a temporary solution here