图片合并与截断

 

from PIL import Image
import time
width, height = 1080, 720
img = '123.png'
img_open = Image.open(img)
(img_w, img_h) = img_open.size
img_w,img_h=min(img_w,width),min(img_h,height)
merge_img = Image.new('RGB', (width, height), 0xffffff)
merge_img.paste(img_open, (int((width - img_w) / 2), int((height - img_h) / 2)))
resjpg = 'res{}.jpg'.format(int(time.time()))
merge_img.save(resjpg, quality=70)


posted @ 2018-08-06 10:55  papering  阅读(240)  评论(0编辑  收藏  举报