Write a program to display the properties of a .bmp file? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

Write a program to display the properties of a .bmp file?

1. File type 2. File size 3. Bits per resolution 4. Image height 5. Image width

29th Oct 2019, 11:58 AM
kundan sharma
kundan sharma - avatar
4 Answers
+ 3
An other possibility of getting information from an image file is using a library like pillow. So you can get the properties without hassle.
29th Oct 2019, 3:20 PM
Lothar
Lothar - avatar
+ 2
I did that recently. Like ~ swim ~ said, open the .bmp file in binary mode. There are two headers : - general header : bmp signature (BM), the file size, 4 bytes and the offset from beginning of the file where datas are stored. This header has a fixed size of 14 bytes. - second header of unknown size : size of that header, then width and height of the image, then other informations about compression, number of bits per pixel and the size of the datas. While reading the datas, be careful of the 4bytes alignment.
29th Oct 2019, 1:48 PM
Théophile
Théophile - avatar
+ 2
Please avoid writing your question into the Relevant Tags section 👍
29th Oct 2019, 2:41 PM
Ipang
+ 2
~ swim ~ I promise I will keep trying to remind our new friends best I can, when and where I can. But I won't be doing it for a badge bro, I'm just so badly wanting to see the search bar does its work satisfactorily 😁 Tough work being a mod bro, you been there, besides I guess I'm more free as non mod anyway 😁
29th Oct 2019, 2:53 PM
Ipang