The Image class of the PIL library

Import module:

from PIL import Image

1. Image class properties

1. format: the format of the file. Images created by PIL whose file format is None.

from PIL import Image
img = Image.open("./test.png")
print(img.format)

>> PNG

2. mode: the mode of the image.

from PIL import Image
img = Image.open("./test_img.png")
print(img.mode)

>> RGB

3. size: the size of the image. Returned as width and height (width, height)

from PIL import Image
img = Image.open("./test_img.png")
print(img.size)
print(img.size[0])
print(img.size[1])

>> (775,580)
>> 775
>> 580

 

Guess you like

Origin blog.csdn.net/qq_40108803/article/details/116573104