Skip to content
/ pixedit Public

Simple picture editor : remove background

Notifications You must be signed in to change notification settings

lostsh/pixedit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

pixedit

Remove some pixel to make transparent background using PIL

Requirements:

  • Pillow version 1.1.7

Usage

Installing environment :

python3 -m venv .env # Creating virtual environement
source .env/bin/activate # Activating the environment
python -m pip install pillow # Installing the library

Running program :

# To remove all pixels matching the given rgb values :
python main.py -f input.jpg -o output.png -rv 255 -gv 255 -bv 255

# To keep all pixels matching the given rgb values :
python main.py -f input.jpg -o output.png -rv 255 -gv 255 -bv 255 --keep-pixel

Examples :

Removing pixels Keeping only selected pixels
Description Removing white background (all pixels with value 255, 255, 255) Keeping only white pixels
Command line python main.py -f undraw.png -o out.png -rv 255 -gv 255 -bv 255 python main.py -f undraw.png -o white.png -rv 255 -gv 255 -bv 255 --keep-pixel
Input image Undraw icon to demonstrate usage Undraw icon to demonstrate usage
Ouput image Undraw icon to demonstrate usage Undraw icon to demonstrate usage
usage: Pixedit [-h] -f FILE -o OUT [--keep-pixel] [-rv R_VALUE] [-gv G_VALUE] [-bv B_VALUE] [-d]

Pixel Editor

options:
  -h, --help            show this help message and exit
  -f FILE, --file FILE  Input image path
  -o OUT, --out OUT     Output image path
  --keep-pixel          Keep only pixel matching given rgb. By default, it remove all matching rgb pixels
  -rv R_VALUE, --red-value R_VALUE
                        (r,g,b) Red value to remove 0 - 255
  -gv G_VALUE, --green-value G_VALUE
                        (r,g,b) Blue value to remove 0 - 255
  -bv B_VALUE, --blue-value B_VALUE
                        (r,g,b) Green value to remove 0 - 255
  -d, --debug           Enable debug ouput, disabled by default
Removing pixels Keeping only selected pixels
Description Removing only dark cat pixels Keeping only dark cat pixels
Command line python main.py --file undraw_cat.png --out out.png -rv 63 -gv 61 -bv 86 python main.py --file undraw_cat.png --out out.png -rv 63 -gv 61 -bv 86 --keep-pixel
Input image Undraw icon to demonstrate usage Undraw icon to demonstrate usage
Ouput image Undraw icon to demonstrate usage Undraw icon to demonstrate usage