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
image-quantizer-0.0.2.tar.gz
(5.0 kB
view hashes)
Built Distribution
Close
Hashes for image_quantizer-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f8fb0cf1363f089eb335751ccd5ffe7a0c2df234ee25825157b031007b831308 |
|
MD5 | 2a5e667d617a084d120b8b31922c8ec4 |
|
BLAKE2b-256 | 31c58e66874cf50f64fa08f90c9fb36f3f3cd42a9eae371cea7b2061f81aef7b |