Hacker News new | ask | show | jobs
by elektronaut 3945 days ago
Yep, that's a viable solution. GIF and PNG include the dimensions in the first few bytes. JPEG is a little more complex, but you don't need to download much of the file to get dimensions.

I've used fastimage with success: https://github.com/sdsykes/fastimage

1 comments

For nodejs there's https://github.com/netroy/image-size

From testing with 1800+ image URLs, you can almost certainly get the dimensions within the first 64kb.