image-js / fast-png

PNG image decoder and encoder written entirely in JavaScript
MIT License
329 stars 17 forks source link

Feature request: Export function for png signature check #30

Closed dotKokott closed 6 months ago

dotKokott commented 1 year ago

It would be great if the library would export a isPng(data: ImageData) : boolean function that does the png signature check (which is already happening internally)

This way I could avoid catching the error when trying to decode a non-png and just check pre-emptively.

targos commented 1 year ago

SGTM. Would you like to make a PR?