只需3行代码5秒就能抠图的 Python 神库--removebg==」官方网址:https://www.remove.bg

 官方网址:www.remove.bg

需要申请API:https://www.remove.bg/zh/api

PS:每一个API每月只可以免费使用50次,超出需要付费,请知悉...

先安装一下所需要的库 

pip install removebg
""" 
@Author: Liang
@Date: 2020-07-14 10:23:55
@LastEditTime: 2020-07-14 15:18:05
@LastEditors: Please set LastEditors
@Description: Python 3.8 版本
@FilePath: /undefinedc:/Users/Downloads/只需 3 行代码 5 秒就能抠图的 Python 神库.py
 """

from removebg import RemoveBg
import os

""" 
# 针对单个图片进行抠图...
rmbg = RemoveBg("你的API", "error.log")
path = os.path.join(os.getcwd(),'picture','20190905190611161_看图王.jpg') #图片放到程序的同级文件夹 picture ,也可以改为 path = "C:/Users/Downloads/picture/20190905190611161_看图王.jpg" 
print(path)
rmbg.remove_background_from_img_file(path) 
"""


# 针对批量图片进行抠图...
# 参数填入 api-key, 错误日志路径 
rmbg = RemoveBg("你的API", "./error.log")
# 处理后的图片存放位置
path = os.path.join(os.getcwd(), "picture")

for pic in os.listdir(path):
    rmbg.remove_background_from_img_file(os.path.join(path, pic))
    print(os.path.join(path, pic))

 

你可能感兴趣的:(Python,python,removebg,ps,Python库,提升效率)