Skip to main content

Convert image into quantized image compatible with Waveshare epaper display

Project description

Install and Test

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")

input example image

quantized example image

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()

quantized example image

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: quantized example image

Single palette color images:

quantized example image quantized example image

Project details


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 details)

Uploaded Source

Built Distribution

image_quantizer-0.0.2-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

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

Hashes for image-quantizer-0.0.2.tar.gz
Algorithm Hash digest
SHA256 eea36e1f07b0463f0031e438d2bf90e0574a33425dc4d3740fa604892364212e
MD5 ec11262c637d5ce37322450aee5bceb1
BLAKE2b-256 e9b759e0d35ff75493a7b73911f0914f10195e37d7a9e3c536c3c11e975822b6

See more details on using hashes here.

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

Hashes for image_quantizer-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f8fb0cf1363f089eb335751ccd5ffe7a0c2df234ee25825157b031007b831308
MD5 2a5e667d617a084d120b8b31922c8ec4
BLAKE2b-256 31c58e66874cf50f64fa08f90c9fb36f3f3cd42a9eae371cea7b2061f81aef7b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page