Convert image into quantized image compatible with Waveshare epaper display
Project description
Image Quantizer
Simple Python package to convert an image into a quantized image using a customizable palette. Resulting image can be displayed by ePaper displays such as Waveshare displays.
Installation
It can be installed as a PyPi package
pip install --user image-quantizer
It can also be installed manually
git clone https://github.com/lobis/image-quantizer
cd image-quantizer
python3 setup.py install --user
Usage
from image_quantizer import quantize_image
with Image.open("tests/data/cliff.jpg") as image:
quantized_image = quantize_image(image, palette=PALETTES["WAVESHARE-EPD-7COLOR"])
quantized_image.save("cliffs-quantized.png")
Custom palette
from image_quantizer import quantize_image, PALETTES
# Existing palette names
print(PALETTES)
palette = [
[0, 0, 0], # white
[255, 255, 255], # black
[0, 0, 255], # blue
[0, 255, 0], # green
]
with Image.open("tests/data/cliff.jpg") as image:
quantized_image_custom = quantize_image(image, palette=palette)
quantized_image_custom.show()
Split by Palette
In some cases such as highlighted here, it might be useful to split an image into its colors. This is necessary to display the image in a waveshare RED-WHITE-BLACK display.
from image_quantizer import quantize_image, split_image_by_color
with Image.open("tests/data/cliff.jpg") as image:
quantized_image = quantize_image(image, palette=PALETTES["BLACK-WHITE-RED"])
split_images = split_image_by_color(image)
for color, image in split_images:
image.show()
Original image:
Single palette color images:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file image-quantizer-0.0.2.tar.gz.
File metadata
- Download URL: image-quantizer-0.0.2.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eea36e1f07b0463f0031e438d2bf90e0574a33425dc4d3740fa604892364212e
|
|
| MD5 |
ec11262c637d5ce37322450aee5bceb1
|
|
| BLAKE2b-256 |
e9b759e0d35ff75493a7b73911f0914f10195e37d7a9e3c536c3c11e975822b6
|
File details
Details for the file image_quantizer-0.0.2-py3-none-any.whl.
File metadata
- Download URL: image_quantizer-0.0.2-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f8fb0cf1363f089eb335751ccd5ffe7a0c2df234ee25825157b031007b831308
|
|
| MD5 |
2a5e667d617a084d120b8b31922c8ec4
|
|
| BLAKE2b-256 |
31c58e66874cf50f64fa08f90c9fb36f3f3cd42a9eae371cea7b2061f81aef7b
|