Skip to main content

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
Original 1.png 2.png

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 by mask_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.

Metadata

Release files for img-masker 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for img-masker 1.0.2
File Size Uploaded Provenance Actions
img_masker-1.0.2.tar.gz 4.3 kB Without provenance Details for img_masker-1.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for img-masker 1.0.2
File Interpreter ABI Platform Actions
img_masker-1.0.2-py3-none-any.whl Python 3 none any Details for img_masker-1.0.2-py3-none-any.whl

Total release size: 8.5 kB

Release files / img_masker-1.0.2.tar.gz

Download URL img_masker-1.0.2.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
bde6412ce591ed053deebb108e91adf931aec6096c471fb249b56615c8b855ad
BLAKE2b-256 checksum
How to use checksums
54e79b238659f3d2880f67efcf317fb10ed54fbed5777f30f38bd1885622f04f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.2

Release files / img_masker-1.0.2-py3-none-any.whl

Download URL img_masker-1.0.2-py3-none-any.whl
Size 4.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f4d8a16e91505bfebbee9d9b7b09a1fe267cb1740c5a98708d5e6af488d636d6
BLAKE2b-256 checksum
How to use checksums
23a7e586a15b1804be367749962373b2d644202ca94d9447275abe19b4d716f1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.2

Security for img-masker 1.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page