Skip to main content

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.

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", # Can also be remove since black is default mask_color
    bg_color="white", # Can also be remove since white is default bg_color
    filter_color="transparent" # Can also be remove since transparent is  default filter color
)
masked_img.save("masked.png")

License

This project is licensed under the MIT License. See LICENSE for details.

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

img_masker-1.0.0.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

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

img_masker-1.0.0-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file img_masker-1.0.0.tar.gz.

File metadata

  • Download URL: img_masker-1.0.0.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

Hashes for img_masker-1.0.0.tar.gz
Algorithm Hash digest
SHA256 d1796592db397bc925857d69cceb4e86e5b2012e21b92715576d0eb5974a2e12
MD5 fd71cef72ff8b2bf00c7cf04009bf4d5
BLAKE2b-256 03150cd8a9a82f6b9b25828aeade42c8c2c83810f426de4f4762c7a28c8a9615

See more details on using hashes here.

File details

Details for the file img_masker-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: img_masker-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for img_masker-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 996e9189a711bd54f6cec0f55ca336cfcce184caf752a5e6099817f8346e16ed
MD5 afb0820a6d604bd88285214ce40c4353
BLAKE2b-256 c5a87cd38e2db30ed5db85e85244c6e563584641d0e6a86672601d68a46f5c22

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