Hacker News new | ask | show | jobs
by bzbarsky 3879 days ago
The obvious answer is that the library may not do what you want. Some examples of what browsers want to do with images in different circumstances:

1) Just determine some metadata about the image (size and a few other things) but don't decode the pixel data yet.

2) Asynchronously decode the pixel data on a separate thread, notify when done.

3) Synchronously decode the pixel data on the current thread.

4) Asynchronously decode the pixel data on a separate thread, notify as you go. This can have variants along the lines of "Progressive JPEG" as opposed to just delivering more scanlines.

Now ideally a good library would in fact let you do all of this as needed (e.g. Firefox just uses libpng for PNG decoding, though even there it's patched locally to add APNG support). Not all image formats have good libraries.