I have a white-small.bmp file (32 x 32 px) and i need to get its pixel size to use it later in code. I wonder if there is a function for example:
get_size_of_bmp('white-small.bmp')
which returns int: 32*32 which is 1024
or list [32, 32]
,
(1024 is enough information for my application)
Is there a function in python 3, that returns a pixel size of .bmp file? (not using special library)
Asked
Active
Viewed 153 times
-1

python_newbie
- 3
- 2
1 Answers
0
There is no builtin function that comes to my mind, but there is a library that enables you to get this information easly.
image = PIL.Image.open("image_name.bmp")
width, height = image.size

robocat314
- 141
- 8
-
I cant use PIL library – python_newbie Dec 05 '21 at 14:22
-
Take a look at https://stackoverflow.com/questions/8032642/how-to-obtain-image-size-using-standard-python-class-without-using-external-lib – robocat314 Dec 05 '21 at 17:43