Skip to main content

A very compact representation of an image placeholder

Project description

thumbhash-py

A Python port of the thumbhash encoder by Evan Wallace

Installation

Install thumbhash with pip

pip install thumbhash-py

Optionally install with pillow support:

pip install thumbhash-py[pillow]

Usage

Encode a RGBA array to a ThumbHash

from thumbhash import rgba_to_thumb_hash


rgba = [100, 85, 15, 255, 100, 84, 32, 255,...]
width = 100
height = 75

thumb_hash = rgba_to_thumb_hash(rgba, width, height) # [86, 8, 10, 13, 128, 22, 234, 86, 111, 117, ...]

Open an image using pillow, scale down to max dimensions of 100x100 and encode to a ThumbHash

from thumbhash import image_to_thumb_hash

thumb_hash = image_to_thumb_hash('image.jpg') # [86, 8, 10, 13, 128, 22, 234, 86, 111, 117, ...]

Features

As of now this library only handles the conversion of images to hashes, not the reverse.

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

thumbhash_py-0.1.2.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

thumbhash_py-0.1.2-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file thumbhash_py-0.1.2.tar.gz.

File metadata

  • Download URL: thumbhash_py-0.1.2.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.2

File hashes

Hashes for thumbhash_py-0.1.2.tar.gz
Algorithm Hash digest
SHA256 9c1494d9a7c23de817118f99816b3ff05344af886bc430cd8684157b708c8a17
MD5 a3492f77866961dcc39601608e24d757
BLAKE2b-256 b687b90bed9fc305e1656e2624234fdfa3dd3d1cdd2ab0978a94cff9cd0e2ded

See more details on using hashes here.

File details

Details for the file thumbhash_py-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for thumbhash_py-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1805077fb0cd6a6ed4f435cff7297a5e8a21893ab6be5e759bec70107d1fc45a
MD5 3269220c7b4ba90ecdc374f7b50c3ef8
BLAKE2b-256 c6344beaa5aa3f56012282fd1f9153a269eaf0921c0e3843e12e845a6cacea52

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