Closed ain closed 10 years ago
IEND is supposed to mark the end of the image, so this library doesn't parse beyond that point at all. You could imagine cases where a PNG image is embedded in another file, and there is valid data in that file after the PNG image ends. We wouldn't want the parser to throw an error in that case. Thus, I think that kind of out of bounds checking is out of scope of this library.
If you want to do a manual check as a user of the library, however, you could check whether png.pos < png.data.length
after parsing is complete to see if there is more data that hasn't been parsed.
Fair enough, I can understand the considerations, thanks for the reply.
P.S. the above comparison is a bit faulty so I resorted to a slightly different condition for the trailing overhead business: pngcheck.js:41.
Since the library also detects corrupt files in terms of being incomplete, I'd expect it to also detect any corrupt images that have data succeeding
IEND
and breaking image minification tools for example, e.g. grunt-contrib-imagemin withExample image:![extraneous](https://f.cloud.github.com/assets/370576/2438497/47ebdfe4-adf2-11e3-8061-65e0d4ebf3a5.png)