lucach / meta-png

JavaScript library to store and retrieve metadata in PNG files
27 stars 2 forks source link

Library sometimes creates invalid pngs #5

Closed FRSgit closed 1 year ago

FRSgit commented 1 year ago

Hey @lucach!

Sorry for me being here again, but one of my users found out an issue regarding png generation.

I'll link his description for better clarity: https://github.com/FRSOURCE/cypress-plugin-visual-regression-diff/issues/184#issue-1453510530

There are example pngs to be downloaded at the end of his message.

I have confirmed that for some images indeed meta-png is generating invalid PNGs, but I'm not quite sure why yet. I'll will add a comment here if I find anything.

Please let me know if you know what might be the issue 🤞

lucach commented 1 year ago

Hi @FRSgit , I think we're being hit again by the same problem described in #4 that has to do with how Node.js optimizes Buffer w.r.t. their underlying ArrayBuffers when the data is smaller than Buffer.poolSize (8KB on my system, consistent with what your user is reporting: the example PNG is ~ 1KB).

I should have fixed the logic everywhere now (and released the fix as part of version 1.0.5).

FRSgit commented 1 year ago

Thanks @lucach for quick fix and the explanation - I've also reviewed your changes and they seem to be on point. Thank you again! I'll let you know if there are any more issues, hopefully there are non left 😄