To execute under python3, you first need to install pillow
pip3 install pillow
from PIL import Image image_name='logo.jpg' img=Image.open(image_name) print(img.size) print(img.mode) #convert to black/white picture img=img.convert('L') #img.show() #img.save('f.jpg') #Reduce the picture w,h= img.size #If the image is too large, scale the height and width if w > 100 : h=int((100/w)*h) w=100 #Prevent the quality from degrading when the image is zoomed, add a filter parameter img= img.resize((w,h),Image.ANTIALIAS) img.save('ff.jpg')