8
In PHP and other programming languages, it is possible, through some special functions, to discover the image size.
For example:
list($width, $height) = getimagesize('images/icon.png');
I was curious to know how languages do this. Where does the information that the image has that size come from?
I wanted to understand how it is made the reading of this information.
My doubt arose because when I asked that question How to know the number of lines a large file has in php?, I realized that in my tests, large files took too long to be processed.
But when I did the test with images large and small, to know the size of them, the response time was the same. So, apparently, the function responsible for capturing this information didn’t read the whole file, but returned this information from somewhere.
And what I wanted to know is where this information comes from?
How is it possible to know, for example, the mime of an image with such agility? I say "agility", because even if an image had 20MB, the speed of reading this information is always the same.
Where is this "information" stored? How is the image size processing done?
The key to understanding is contained in metadata. The answer to the question is not complex but to be complete is long...
– MagicHat