Closed agcty closed 3 years ago
Sorry, due time constrains, can't participate in generic programming talks. May be, if you ask something more concrete, i could try to explain. Start with reading sources of sync method, those are trivial.
Alright, perfectly understand!
My main question is where do you actually get the information from? From the header of the remote source?
If you ask about remote images - information is taken from remote source. It does not depend on extension, mime type and so on. Downloads starts and is immediately tested by multiple parsers in parallel https://github.com/nodeca/probe-image-size/tree/master/lib/parse_stream.
Each parser needs very few data to decide if it succeeds or fail. So, when each got decision - download is terminated and joined decision is returned.
That's a principal difference with other solutions - no need to load full source into memory.
If you need to understand, what exactly is tested - see sync variant, it does the same, but looks much more simple https://github.com/nodeca/probe-image-size/tree/master/lib/parse_sync
@puzrin ah i see! thank you very much for your explanation!
How does this library work as in what's the technical background behind it and not how you use it?
I'd love to understand how that library works behind the scenes but I'm having some difficulties understanding what's going on in the source code. Can anybody shed a little light on this? 🤗