A simple image masking tool.
Project description
img-masker
A simple and lightweight Python tool for masking specific colors in images. Supports both local files and remote image URLs. Built on top of Pillow for image processing.
Sample Output
| Original Image | Masking Sample 1 | Masking Sample 2 |
|---|---|---|
Sample Image: Meoscarada image credit to PokeAPI.
Features
- Mask (replace) pixels of a specific color or transparency in an image.
- Supports both local image files and remote image URLs.
- Customizable mask and background colors.
Installation
You can install img-masker using pip:
pip install img-masker
Requirements
Usage
Basic Example
from img_masker import mask
# Mask all transparent pixels in an image with black, set background to white
masked_img = mask("https://example.com/image.png",)
masked_img.show()
Parameters
image_url(str): Path to a local image file or a remote image URL.mask_color(str): Color to use for masked pixels (default:"black"). Accepts any Pillow-compatible color string, e.g.,"red","#FF0000","transparent".bg_color(str): Color for non-masked pixels (default:"white").filter_color(str): Target color to mask (default:"transparent"). Pixels matching this color will be replaced bymask_color.
Masking a Specific Color
# Mask all pure red pixels with blue, set background to white
masked_img = mask(
"input.jpg",
mask_color="blue",
bg_color="white",
filter_color="red"
)
masked_img.show()
Masking Transparent Pixels
# Mask all transparent pixels with black, keep others white
masked_img = mask(
"input.png",
mask_color="black",
bg_color="white",
filter_color="transparent"
)
masked_img.save("masked.png")
License
This project is licensed under the MIT License. See LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file img_masker-1.0.1.tar.gz.
File metadata
- Download URL: img_masker-1.0.1.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e1bc404a52a4ac6e15bd11932b8035334bc059bad6e762f58ed9230cec76fa6c
|
|
| MD5 |
8b00d2d953fee942ed210c5b10fff8e0
|
|
| BLAKE2b-256 |
6dda1bd7e8ed5e64aaffa54325843676565924d766516e47ffc0d96570216fab
|
File details
Details for the file img_masker-1.0.1-py3-none-any.whl.
File metadata
- Download URL: img_masker-1.0.1-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b39d0cba5d01698a1f6cf943fe3005641d062a6e0d0ca20ad97635baca0ef22
|
|
| MD5 |
99453e79305783eeb4576adff5223578
|
|
| BLAKE2b-256 |
30ab02831a92cd1569655a7c7150a942e87ddd2f0986fa094854f6df3409a265
|