调整图像的亮度
1 from PIL import Image,ImageEnhance 2 img = Image.open(r'C:\Users\87823\Desktop\tree.png') 3 w,h = img.size 4 # print('w:',w,'h:',h) 5 # 创建图像区域 6 img_output = Image.new('RGB',(3*w,h)) 7 #将原图复制到(0,0) 8 img_output.paste(img,(0,0)) 9 #获取亮度调整器 10 img_bright = ImageEnhance.Brightness(img) 11 # 增强亮度 12 imgb = img_bright.enhance(1.5) 13 img_output.paste(imgb,(w,0)) 14 # 减弱亮度 15 imgb = img_bright.enhance(0.5) 16 img_output.paste(imgb,(2*w,0)) 17 img_output.show()
正是江南好风景