photopea / UPNG.js

Fast and advanced PNG (APNG) decoder and encoder (lossy / lossless)
MIT License
2.1k stars 259 forks source link

Check for optional UZIP dependency throws error (for large images) #80

Closed 1j01 closed 1 year ago

1j01 commented 1 year ago

This line throws ReferenceError: UZIP is not defined: https://github.com/photopea/UPNG.js/blob/a4eafb5c77072162be3a6d968ac67d238a9d01ac/UPNG.js#L813

It should use typeof to safely check for the existence of a global, like so:

    var CMPR = (data.length>10e6 && typeof UZIP!="undefined" && UZIP!=null) ? UZIP : pako;

The UZIP!=null part is still useful in case for example anyone was working around this by setting window.UZIP = null;

photopea commented 1 year ago

What if I check

window.UZIP!=null

that should work, right?

1j01 commented 1 year ago

Yes, that should be fine. The only difference would be in non-browser environments, which probably aren't supported.

photopea commented 1 year ago

Ok, I have uploaded a new version.