-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
Version
- react-native-image-crop-picker v0.41.2
- react-native v0.73.9
Platform
- iOS 17
Expected behaviour
The openPicker options are set as follows:
compressImageMaxWidthis set to2000compressImageMaxHeightis set to2000
The initial image added has a size of 1170x2532px. Since the image height exceeds 2000, it should be resized, with the width adjusted proportionally. The result size should be about 924x2000px.
Actual behaviour
The image is being resized up instead of down. The final image size becomes 2772x6000 px, meaning the height is actually "resized" to 2000 and then multiplied by 3x. I know the cause of this behavior and will explain it here.
Steps to reproduce
- Use library version v0.41.x.
- Set compressImageMaxWidth and compressImageMaxHeight.
- Attempt to add an image with a width and/or height that exceeds these values to trigger the "compression" process and make the bug appear.
Attachments
As noted in this issue, this bug was introduced with this commit.
The problem is that when UIGraphicsImageRenderer is created, it uses a default scale parameter (reference) of 3.0 or 2.0, depending on the device (in my case, it's 3.0 on the iPhone 14) link.
This results in two issues:
- If an image is resized, it ends up with incorrect dimensions.
- For larger images, an error occurs:
iosurface is too large for GPU, because an image that is scaled up 2–3 times (depending on the scale) cannot be processed, as it probably exceedsGL_MAX_TEXTURE_SIZE.
This PR #2075 should probably resolve the issue.