jusewe 2020-07-04
from PIL import Image filename = ‘0bb521255dc1eb1830579959afff9407.webp‘ im = Image.open(filename) if im.mode == "RGBA": im.load() # required for png.split() background = Image.new("RGB", im.size, (255, 255, 255)) background.paste(im, mask=im.split()[3]) save_name = filename.replace(‘webp‘, ‘jpg‘) im.save(‘{}‘.format(save_name), ‘JPEG‘)
from io import BytesIO from PIL import Image import requests # 这里url是你需要下载的图片地址 resp = requests.get(url, headers=headers) byte_stream = BytesIO(resp.content) im = Image.open(byte_stream) # im.show() if im.mode == "RGBA": im.load() # required for png.split() background = Image.new("RGB", im.size, (255, 255, 255)) background.paste(im, mask=im.split()[3]) name = md5_(url) im.save(‘./photo2/{}.jpg‘.format(name), ‘JPEG‘)
try_files $uri $notfound =404;add_header Cache-Control max-age=100;log_not_found off;access_log off;