PIL Imagesave parameters save grey scale image
To save a grayscale image using PIL, you need to pass the mode parameter as 'L'. Here is an example:
from PIL import Image
# Open the image
img = Image.open('image.png')
# Convert to grayscale
img = img.convert('L')
# Save the image
img.save('grayscale_image.png', format='PNG')
In the above code, the convert method is used to convert the image to grayscale by passing the mode parameter as 'L'. Then, the save method is used to save the grayscale image with the format parameter set to 'PNG'.
原文地址: https://www.cveoy.top/t/topic/br9f 著作权归作者所有。请勿转载和采集!