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

Indeterminate result #66

Open
thany opened this issue Dec 15, 2021 · 3 comments
Open

Indeterminate result #66

thany opened this issue Dec 15, 2021 · 3 comments

Comments

@thany
Copy link

thany commented Dec 15, 2021

Describe the bug
When passing a file that isn't an image, AND doesn't have a type, the function never produces a usable result. The responseUriFunc is never called, and an error is never thrown.

To Reproduce
Steps to reproduce the behavior:

  1. Either:
    1. Select a file that your OS or your browser doesn't recognize. For me it's a 7z file, for you it might be something else.
    2. Pass it a bogus file: new File([ /* presumably any data will do */ ], 'foo', { type: '' })
  2. Observe the responseUriFunc and any thrown errors by wrapping the Resizer.imageFileResizer in a try-catch.

Expected behavior
Either of these options:

  • The function returns a promise, like it probably should anyway, that is rejected.
  • The function throws an error.
  • The responseUriFunc callback is called with an empty/undefined parameter. Not recommended, but it might be the last option if the above two can't work.

I noticed in the source code that if the filetype is empty, you just carry on trying to resize the image, which isn't an image. Filetype could never be empty in practice. Any file that is resizable, must also be recognized by the browser, and therefor must also have a valid filetype. Letting empty filetypes through seems like a bad idea.

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser: Firefox
  • Version 95
@iuliathira
Copy link

iuliathira commented Jan 6, 2022

Hi! Did you find a solution to this? I'm facing the same problem trying to write some test using mock data

@thany
Copy link
Author

thany commented Jan 10, 2022

No, but I imagine forking this project might not be a bad idea, seeing how development on this project is not exactly super active. It doesn't seem like it should be awfully difficult to fix.

(not meant to belittle the author - I'm sure he/she has other priorities)

@thany
Copy link
Author

thany commented Feb 22, 2022

I also found that certain PNGs also produce an indeterminate result. I tried these:

  • ❌ 30MB 7680x4320 24bpp PNG
  • ❌ 67MB 7680x4320 24bpp PNG
  • ✔ 2MB 1395x1054 32bpp PNG
  • ✔ 1.3MB 996x704 32bpp PNG
  • ✔ 0.6MB 776x413 32bpp PNG

This is just what I happen to have at hand. More testing is neccesary to get to a safe conclusion, but it seems like large PNG might be the possible culprit. I currently have no way to be sure how large is too large, if that's the problem.

I'm pretty sure this is new. I've seen the above two failing PNGs work, but somehow it's now broken.

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