Like the Title, is this possible?
I only need the width and height, so loading the image into ram would be unnecessary.
Check this SO question: Getting image dimensions without reading the entire file
This shows you how to extract this information from the image header without reading the entire file. Usually, the image files contain metadata at the start containing width and height in addition to other data, so that will be the quickest way of retrieving this information.
There is example code here that shows how you can read the header of images to get the width and height without loading and decoding the entire file. Obviously the approach is different for different image types though, so you may need to write your own if you are using something a little more exotic.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With