Python制作证件照
https://zhuanlan.zhihu.com/p/135912129可以考虑用wxPython写个界面
from PIL import Image
from removebg import RemoveBg
# 修改照片背景色
def change_bgcolor(file_in, file_out, api_key, color):
rmbg = RemoveBg(api_key, 'error.log')
rmbg.remove_background_from_img_file(file_in)
no_bg_image = Image.open(file_in)
x, y = no_bg_image.size
new_image = Image.new('RGBA', no_bg_image.size, color=color)
new_image.paste(no_bg_image, (0, 0, x, y), no_bg_image)
new_image.save(file_out)
# 修改照片尺寸
def change_size(file_in, file_out, width, height):
image = Image.open(file_in)
resized_image = image.resize((width, height), Image.ANTIALIAS)
resized_image.save(file_out) 证件照还真不错。自己拿着手机在家就可以拍了,以前都去照相馆。
页:
[1]