Skip to content

This is a script that will mask a PNG image with a specified color. The default option will replace all non-transparent pixels with the inputed color, which is handy for editing single color icons.

License

Notifications You must be signed in to change notification settings

macuyler/color-mask

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

color-mask

This is a script that will mask a PNG image with a specified color. The default option will replace all non-transparent pixels with the inputed color, which is handy for editing single color icons. You can also replace a specified color inside the image using the -r (replace) option.

Get Started

# Setup
pip3 install -r requirements.txt


# Usage

> Replace non-transparent pixels with an inputed color.
 ./color-mask ./PATH_TO_INPUT_FILE ./PATH_FOR_OUTPUT '#HEXCODE' [OPTIONS]
    (The Input file should be a PNG image)

    * OPTIONS:
      -s            : Show a preview of the new Image at the end.
      -r '#HEXCODE' : Replace only pixels matching the following HEXCODE.
      -rd '#HEXCODE' : Replace pixels darker than the following HEXCODE.
      -rl '#HEXCODE' : Replace pixels lighter than the following HEXCODE.


> List all colors contained in an image.
 ./color-mask colors ./PATH_TO_IMAGE_FILE
    (The Image file should be a PNG image)

Hex Codes

All inputed hexcodes must begin with #. A hexcodes can be inputed as a 3, 6 or 8 digit code.

Hex Code Formats:

  • 3 digits: #RGB
  • 6 digits: #RRGGBB
  • 8 digits: #RRGGBBAA

Examples:

  • #ddd --> rgba(221, 221, 221, 255)
  • #2e2e2e --> rgba(46, 46, 46, 255)
  • #ff0000aa --> rgba(255, 0, 0, 170)

About

This is a script that will mask a PNG image with a specified color. The default option will replace all non-transparent pixels with the inputed color, which is handy for editing single color icons.

Topics

Resources

License

Stars

Watchers

Forks

Languages