Skip to main content

A lightweight Python tool for removing green screen backgrounds from images, converting them into transparent PNGs for easy compositing and editing.

Project description

📘 GreenRemover

English | 中文

GreenRemover 是一个简洁高效的 绿色背景抠像工具,基于 Python 实现,支持将带绿幕的图像转换为带透明通道的 PNG,方便后续合成与二次创作。

输入示例 输出示例


✨ 功能特性

  • 🎯 精准抠绿:自动识别纯绿及偏绿色区域并去除
  • 🖼️ 透明输出:输出为带透明通道的 PNG 格式
  • 轻量快速:依赖少,安装简单,可直接命令行使用
  • 🔧 可扩展:核心算法封装为函数,支持二次开发

📦 安装方法

方式一:通过 uv

git clone https://github.com/avatarreal/greenremover.git
cd greenremover
uv sync

方式二:通过 pip

pip install greenremover

🚀 使用方法

1. 命令行使用

安装完成后,你可以直接运行命令:

greenremover input.png output.png
  • input.png:输入的带绿幕图像
  • output.png:输出的抠像结果(带透明背景)

2. 作为库调用

你也可以在 Python 中直接调用:

from PIL import Image
from greenremover.core import remove_green

img = Image.open("input.png")
out = remove_green(img)
out.save("output.png")

🧪 开发与测试

安装开发依赖

uv sync --group dev

运行单元测试

uv run pytest

代码检查与格式化

uv run ruff check greenremover tests   # 代码规范检查
uv run black greenremover tests        # 自动格式化
uv run mypy                            # 静态类型检查

📂 项目结构

greenremover/
├── greenremover/
│   ├── __init__.py      # 包入口
│   ├── core.py          # 核心抠像算法
│   └── cli.py           # 命令行接口
├── tests/               # 单元测试
│   └── test_core.py
├── assets/              # 示例图片
├── README.md
├── pyproject.toml       # 项目配置
└── LICENSE

📜 许可证

本项目使用 MIT License 开源。
你可以自由地使用、修改和分发本项目,但请保留原始许可证声明。

注:以上为简要说明,若与英文原文有冲突,以 LICENSE 文件中的英文条款为准。


🌟 致谢

  • Pillow — 图像处理库
  • NumPy — 数值计算库
  • 社区灵感与支持 ❤️

GreenRemover:让抠像更简单、更纯粹。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

greenremover-0.1.0.tar.gz (658.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

greenremover-0.1.0-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file greenremover-0.1.0.tar.gz.

File metadata

  • Download URL: greenremover-0.1.0.tar.gz
  • Upload date:
  • Size: 658.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.19

File hashes

Hashes for greenremover-0.1.0.tar.gz
Algorithm Hash digest
SHA256 34e3da81270f763242a8df66c6d64946e90ea3fcd5b2be140581c3b8ccd61799
MD5 2c1a6012d6153e03982b52b0eb4886b8
BLAKE2b-256 2c3cf095aa5c6da8f961f50028754e18e7cb91286ce97878b7a67dde1ee29e69

See more details on using hashes here.

File details

Details for the file greenremover-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for greenremover-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a4d52d33cba57f21ee8a3771093f473c125d2e8c69e0d1bbcf11fa8c54ce2dcf
MD5 5e7394cc8fad19ab46498669dd4256ba
BLAKE2b-256 f41365124ed5de081bf7103fb99cb429cf9a23201b49043ad9d1ab3faa1515a4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page