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.1-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 91a4476f0551538255a867576cbd033c486e1487467ce7e2319a2fbcc17a0281 |
|
MD5 | c3dd705bb4c502aa5291c19929da41a3 |
|
BLAKE2b-256 | 77be0b2b8aef0cd4d16eb1a22424e131db998ad1795407bb8ca2420f9ae02805 |
Hashes for blurhash_python-1.2.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d7836629923f65141c945503f22b8ee009d256952c852218bedbf2475d1a2a68 |
|
MD5 | bc74884e3e558e2cb9890b20be9b33fc |
|
BLAKE2b-256 | f3f056441d3d8baf6e9dd1e52e791d6cf1790a5ba40d0bc3076bcf82bd54ace0 |
Hashes for blurhash_python-1.2.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 62a98d7c02ed78df15645276a084969791a22149eebf1dfe6295b188a3e248c6 |
|
MD5 | cf20b75af5b0e70aa4009cdc1f3bd33c |
|
BLAKE2b-256 | 670c61379e48c218d3db6d178d04fb3ab08ece4aaad85dcfc049707ba2e483e4 |
Hashes for blurhash_python-1.2.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c4455a534480cec6555635541901bbb4f867050cb927266132e753a233e2f15b |
|
MD5 | 97fe90aed3eba9a039e8f050d954cc52 |
|
BLAKE2b-256 | f77db4f5df7ec445fbd3e27223ea273c50a5896b97940e8f958fbac49d4cb515 |
Hashes for blurhash_python-1.2.1-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b7afa9d0783e764f60b4b873e5dddf13b99ca559a6011ed343ae22964fda4df4 |
|
MD5 | 8a19895039cd122bd0671969af08cfd8 |
|
BLAKE2b-256 | 3f16720c92beea295a980d71d352814b75e50c1ad2e7d06a4410f42741e3335a |