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

Compression fails on iOS when maxWidthOrHeight is not specified #166

Closed
agonzalezjr opened this issue Oct 20, 2022 · 1 comment
Closed

Comments

@agonzalezjr
Copy link

I am using iPad with iOS 16 and a modified version of the test website that does the following to remove the maxWidthOrHeight option:

        var options = {
          maxSizeMB: parseFloat(document.querySelector("#maxSizeMB").value),
          maxWidthOrHeight: parseFloat(
            document.querySelector("#maxWidthOrHeight").value
          ),
          useWebWorker: useWebWorker,
          onProgress: onProgress,
        };

        // andy updates start
        delete options.maxWidthOrHeight;
        console.log(`>>> options = ${JSON.stringify(options)}`);
        // andy updates end

I am using this image (it's 4.8 MB original size)

trees

Compression is "stuck" at around 25% and an error is thrown. See console:

ipad-console-failure-log

--

Docs in the README read as:

// you should provide one of maxSizeMB, maxWidthOrHeight in the options
const options: Options = { 
  maxWidthOrHeight: number,     // compressedFile will scale down by ratio to a point that width or height is smaller than maxWidthOrHeight (default: undefined)
                                // but, automatically reduce the size to smaller than the maximum Canvas size supported by each browser.
                                // Please check the Caveat part for details.

And in "Caveats"

Each browser limits the maximum size of a Canvas object.
So, we resize the image to less than the maximum size that each browser restricts.
(However, the proportion/ratio of the image remains.)

So I assumed not using this option would mean a sensible default would be plugged in by the library.

Is there some code you use to calculate this default if that is the case?

@agonzalezjr
Copy link
Author

This might be related to #165 👀

This was referenced Mar 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants