Python 将彩色图片转换成黑白图片
1 from PIL import Image 2 3 4 def image_convert(): 5 im = Image.open("image/ball.png") 6 # 将彩色图片转换成黑白图片 7 bw_image = im.convert("L") 8 bw_image.save("image/ball.jpg") 9 print("~~~~~~~~~~~~~~>>>图片转换完成<<<~~~~~~~~~~~~~~") 10 11 12 if __name__ == '__main__': 13 image_convert()