browser-image-resizer icon indicating copy to clipboard operation
browser-image-resizer copied to clipboard

Canvas Area Exceeds Maximum Limit on iOS Safari

Open cod3master opened this issue 8 months ago • 0 comments

Issue: Canvas Area Exceeds Maximum Limit on iOS Safari

Description

When attempting to resize large images on iOS using Safari, the process fails due to the browser's limitations. Specifically, this issue arises because Safari restricts the canvas area to a maximum size (width * height > 16777216). As a result, resizing large images leads to failures, often resulting in a black image being sent to the server.

Steps to Reproduce

  1. Open Safari on an iOS device.
  2. Attempt to resize a large image (e.g., an image with dimensions that exceed the maximum canvas area).
  3. Observe the failure and the resulting black image.

Expected Behavior

Large images should either:

  • Not be resized if the canvas size exceeds the maximum limit.
  • Be resized using an alternative method that does not rely on the canvas.

Actual Behavior

The resizing process fails, and a black image is sent to the server.

Suggested Solution

Implement a check for the canvas size before resizing. If the size exceeds the limit, either:

  • Skip the resizing process, or
  • Use a different resizing method that does not involve the canvas.

Additional Information

While resizing images before uploading is typically desired, it is preferable to avoid sending a black image due to resizing issues. This solution aims to provide a more graceful fallback for handling large images in Safari on iOS.

cod3master avatar Jun 12 '24 08:06 cod3master