Skip to main content

pillow_snippet

some useful snippet and utils using pillow to handle image

Requirements

  • Pillow

Install

pip install pillow-snippet

Documentation

Tutorial

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

circle-image

  • 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)
exclude_white_image.save("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")
change_to_red_image.save("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")
change_to_green_image.save("test_result/change_to_green_image_L.png")
change_to_green_image = mask2.convert_to_single_color("#00ff00ff", mode="opacity")
change_to_green_image.save("test_result/change_to_green_image_opacity.png")

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

Contribution

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

Metadata

Release files for pillow-snippet 0.0.4

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

Source distribution (sdist)

Source distribution for pillow-snippet 0.0.4
File Size Uploaded
pillow-snippet-0.0.4.tar.gz 2.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pillow-snippet 0.0.4
File Interpreter ABI Platform
pillow_snippet-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 7.3 kB

Release files / pillow-snippet-0.0.4.tar.gz

Download URL pillow-snippet-0.0.4.tar.gz
Size 2.9 kB
Tags Source
SHA-256 checksum
How to use checksums
ff64b8c8728efae11d8fb04bd5f35168b4808a811e3fc24b6159a8b8415d7f7e
BLAKE2b-256 checksum
How to use checksums
30101d3dd4e8737944ea23f343297adc82afbd65956463d5c002205265e29b99
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.7.3

Release files / pillow_snippet-0.0.4-py3-none-any.whl

Download URL pillow_snippet-0.0.4-py3-none-any.whl
Size 4.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6239776b63b8014d94a2b15f55803f2022ae7b58ac43fb9453523f8c6238ce4f
BLAKE2b-256 checksum
How to use checksums
badf81710501c64cd866644fb84abc3ab071d7b50e137a971eb8f0abb905987d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.7.3

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 release files

0.0.3

2 release files

0.0.1

2 release files

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