Хотите автоматизировать обработку изображений без фотошопа?
Скрипт-проект на базе библиотеки rembg:
Установка:
Python
pip install rembg
Пример кода:
Python
from rembg import remove
def remove_background(input_path: str, output_path: str) -> None:
"""Удаляет фон с изображения и сохраняет результат."""
with open(input_path, 'rb') as input_file:
with open(output_path, 'wb') as output_file:
image_bytes: bytes = input_file.read()
output_bytes: bytes = remove(image_bytes)
output_file.write(output_bytes)
if __name__ == "__main__":
remove_background('input.png', 'output.png')
Открывает файл;
Убирает фон;
Сохраняет готовое изображение.
GitHub/Инструкция
Разъяснивший Python
