0
点赞
收藏
分享

微信扫一扫

使用python rembg替换登记照背景方法

参考材料: https://pypi.org/project/rembg/


from rembg import remove
from PIL import Image

input_path = 'input.jpg'
output_path = 'output.png'

in_image = Image.open(input_path)
no_bg_image = remove(in_image)    #删除背景

x, y = no_bg_image.size

new_image = Image.new('RGBA', no_bg_image.size, color='blue')
new_image.paste(no_bg_image, (0, 0, x, y), no_bg_image)
new_image.save(output_path)


举报

相关推荐

0 条评论