ericnograles / browser-image-resizer

A tiny browser-based library to downscale and/or resize images using canvas
MIT License
98 stars 42 forks source link

Canvas Area Exceeds Maximum Limit on iOS Safari #88

Open cod3master opened 4 months ago

cod3master commented 4 months ago

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:

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:

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.