Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

So what are the tricks


The first trick is simply "cut the end of the file off". This saves the adler32 checksum on the end of the zlib stream, the crc32 on the end of the IDAT chunk, and the entire IEND chunk.

This works because modern browsers have support for progressively rendering images that are still being downloaded - as a result, truncation is also handled gracefully.

However, this alone results in rendering errors - the last few rows of pixels end up missing, like this:

https://cdn.discordapp.com/attachments/286612533757083648/96...

I don't know the precise reason for this, but I believe the parsing state machine ends up stalling too soon, so I threw some extra zeroes into the IDAT data to "flush" the state machine - but not enough to increase the file size.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: