Skip to content

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

@wrldh

Description

@wrldh

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions