Skip to main content

some useful snippet for image

Project description


some useful snippet and utils using pillow to handle image


  • Pillow


pip install pillow-snippet



  • origin image
  • origin image2
  • convert an Image to a circled Image
from pillow_snippet import convert
origin_image ='colorful_example.png')
image = origin_image.resize((200, 200))
circle_image = convert.circle_image(image)"test_result/circle_image.png")


  • delete the white pixel from an image
    it seems there is still white but if fact it is transparent. You can open the image in new tab to see more details
mask = Mask(image)
exclude_white_image = mask.get_exclude_white_image(tolerance=8)"test_result/exclude_white_image.png")

no white image

  • convert the image to only contains red color according it's brightness
mask = Mask(image)
change_to_red_image = mask.convert_to_single_color("#ff0000ff")"test_result/change_to_red_image.png")

only red image

  • convert the imge to only contains green color according it's opacity instead of it's brightness
mask2 = Mask(origin_image2)
change_to_green_image = mask2.convert_to_single_color("#00ff00ff", mode="L")"test_result/change_to_green_image_L.png")
change_to_green_image = mask2.convert_to_single_color("#00ff00ff", mode="opacity")"test_result/change_to_green_image_opacity.png")

compare difference mode
* mode = "L"
img * mode = "opacity"


  1. clone the code
  2. make your commit
  3. make test
sudo pip install .
  1. create a pull request

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pillow-snippet, version 0.0.4
Filename, size File type Python version Upload date Hashes
Filename, size pillow_snippet-0.0.4-py3-none-any.whl (4.4 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size pillow-snippet-0.0.4.tar.gz (2.9 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page