| 
x
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册  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) |