Skip to content
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

[iOS] Image is being resized up instead of down #2100

Closed
wrldh opened this issue Oct 10, 2024 · 3 comments · Fixed by #2103
Closed

[iOS] Image is being resized up instead of down #2100

wrldh opened this issue Oct 10, 2024 · 3 comments · Fixed by #2103

Comments

@wrldh
Copy link

wrldh commented Oct 10, 2024

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:

  • compressImageMaxWidth is set to 2000
  • compressImageMaxHeight is set to 2000

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

  1. Use library version v0.41.x.
  2. Set compressImageMaxWidth and compressImageMaxHeight.
  3. 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:

  1. If an image is resized, it ends up with incorrect dimensions.
  2. 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 exceeds GL_MAX_TEXTURE_SIZE.

This PR #2075 should probably resolve the issue.

@wrldh wrldh changed the title Image is being resized up instead of down on iOS [iOS] Image is being resized up instead of down Oct 11, 2024
@xhirazi
Copy link
Contributor

xhirazi commented Oct 14, 2024

+1

@xhirazi
Copy link
Contributor

xhirazi commented Oct 15, 2024

fixed in PR

@wrldh
Copy link
Author

wrldh commented Oct 15, 2024

I think it was already fixed here #2075 by specifying proper scale factor for the format. Proper scale factor for this case is always 1.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants