Closed FRSgit closed 2 years ago
Hi @FRSgit ,
thanks for reaching out! I've spent quite some time digging into this very weird issue, and it seems related to the way Node.JS handles Buffer
s (which are supposed to be subclasses of JavaScript TypedArray
, but...).
I wrote an explanation at the best of my current (brittle) understanding of these differences in the commit message and as a comment in the function body: see https://github.com/lucach/meta-png/commit/4777f10a978832d822c85ed7d3ba4c971d300f37.
Hopefully this should fix the issue for your case (I've checked some of the comments in the issue you linked, and the newer implementation seems to work with the last "reproduction" zip that uses Node.JS).
Thanks for suggesting the isPNG
library: I wasn't aware of it. Whenever it makes sense, though, I try to avoid having an extra dependency just for a tiny implementation like this one. (And, perhaps even more importantly, I wanted to understand why the current one was failing while seeming appropriate).
I've released the fix as part of meta-png
1.0.4. Let me know whether it indeed solves the issues on your side!
Thank you @lucach for such a quick fix and detailed explanation!
I've just released new version of @frsource/cypress-plugin-visual-regression-diff
package, lets see if that fixes all of the issues encountered by others
Lately I've got some feedback from users of my package, that a
isPNG
check doesn't work well for all types of PNGs.I'm still trying to figure out what's the exact scenario that makes
isPNG
frommeta-png
to fails sometimes, but I've got confirmation that switching it to the method coming fromis-png
package fixes the issue.So I think it would be beneficial for the
meta-png
library to do this switch internally (is-png
is for sure battle-tested library). What do you think @lucach?