BlurHash encoder implementation for Python
Project description
blurhash-python
This is an encoder for the BlurHash algorithm. To find out more about BlurHash, see https://github.com/woltapp/blurhash.
Installation
Install blurhash with pip
$ pip install blurhash-python
or pipenv
$ pipenv install blurhash-python
Usage
Create blurhash from image file
import blurhash
with open('image.jpg', 'rb') as image_file:
hash = blurhash.encode(image_file, x_components=4, y_components=3)
Alternatively, scale the image to produce a faster hash, and create a blurhash from the in-memory image directly
import blurhash
from PIL import Image
with Image.open('image.jpg') as image:
image.thumbnail(( 100, 100 ))
hash = blurhash.encode(image, x_components=4, y_components=3)
You can also pass file name as parameter to the function
import blurhash
hash = blurhash.encode('image.jpg', x_components=4, y_components=3)
y_components
and x_components
parameters adjust the amount of
vertical and horizontal AC components in hashed image. Both parameters must
be >= 1
and <= 9
.
Development
Install development requirements and package in editable mode
$ pipenv install --dev
Tests
Run test suite with pytest
in virtual environment
$ pytest
Use tox
to run test suite against all supported python versions
$ tox
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 Distributions
Hashes for blurhash_python-1.2.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82210d27e744a1aab3fac59f95f34b9df50aaf300cf132d72588588ce137c746 |
|
MD5 | 5e03ea18f75cf5b4e200e40efecc7231 |
|
BLAKE2b-256 | 8dcf6ab8160491342e4801141538b369472d849052709eab5f3deef7034475de |
Hashes for blurhash_python-1.2.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ecbdd7c4f67787e23ce906940024e64cacc872a21a5e9eb60bcd94bfdb2c5c13 |
|
MD5 | ef70a9ac7d82c6c510d461730308743e |
|
BLAKE2b-256 | 936bde6f885e01b2dba51ea8dd7e3b8d6618b7433bfb920ac3e7d82e1af7e0ca |
Hashes for blurhash_python-1.2.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c44df545af61fc8bb6a16723329a08a47f625278e17cfae6e81487c6d1903ffd |
|
MD5 | 1e0630ddf211dda18a70f77cbfe463d2 |
|
BLAKE2b-256 | 0c24e59cb19f6e44cda9f87905ad20a6d9a2c6e7c70c7bfcbd5197e279a3d6de |
Hashes for blurhash_python-1.2.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b154189c9eb34f72696d724ffd317c6d27f1f68d47e3752b88c3a89ccc44b13f |
|
MD5 | 07f48191ece836c59683108179576aa1 |
|
BLAKE2b-256 | d20adedc791335f0e5d914d0af6db9aca3376eb87e13fff501cb605e84462db9 |
Hashes for blurhash_python-1.2.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7631977ab489eb8d4338347e3d954aca80e2922f21a66c65b12cc1f4e130da71 |
|
MD5 | 93eed0befeb7b1c8491e24f628211fd1 |
|
BLAKE2b-256 | dc0b3b8107235c6e4f552d5f06ad71ecf965ff42eed9f34e93397ffc334f8747 |