Skip to main content

High-performance visual hashing for seamless image loading. Encode images into tiny strings and decode into beautiful, fast-loading blurs

Project description

⚡ useblysh (Python)

High-performance visual hashing for seamless image loading. The unified toolkit for Python and JavaScript to turn heavy images into elegant, byte-sized blurs.

pypi version License: MIT


🌟 Why useblysh?

Standard loading="lazy" leaves users staring at empty white boxes. useblysh eliminates this "broken" feel by encoding your images into tiny strings that can be sent inside your JSON API response.

  • Full-Stack: Identical hashing logic for Python (Backend) and React (Frontend).
  • Zero Layout Shift: Reserve image space instantly to prevent page jumping.
  • Performance: Replace 1MB images with 20-byte strings during the initial load.

🛠️ Installation

Backend (Python)

pip install imghash

🚀 Simple Examples

Generate Hash (Backend)

Generate hashes on your server using the Python library.

from PIL import Image
from imghash import encode

# Open an image using Pillow
image = Image.open("path/to/image.jpg")

# Generate the hash
hash = encode(image, components_x=4, components_y=3)
print(f"Generated Hash: {hash}")

Frontend Compatibility

The hash generated by this Python module is fully compatible with the useblysh JS package. You can encode on your backend and decode on your frontend using the React component.


💡 Use Cases

1. Progressive Image Loading

Instead of showing a spinner or a blank box, show a beautiful blurred version of the actual image. This keeps users engaged and makes the site feel faster.

2. Social Media Feeds

For infinite scroll feeds (like Instagram or Pinterest), send the useblysh string in your initial JSON request. The app can render the entire feed layout with placeholders before a single byte of actual image data is even downloaded.

3. SEO & Layout Stability (CLS)

Prevent "layout shift" where content jumps around as images load. useblysh reserves the correct aspect ratio and space immediately.


📖 How it Works

Blysh uses a Discrete Cosine Transform (DCT) to extract the most important color frequencies from an image.

  1. Encoding: The image is downsampled and converted into a set of mathematical factors, then compressed into a Base83 string.
  2. Decoding: The frontend takes that string and reconstructs a low-resolution version of the original image, applying a smooth blur filter for an elegant look.

Built with ❤️ for the modern web.

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

useblysh-1.0.1.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

useblysh-1.0.1-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file useblysh-1.0.1.tar.gz.

File metadata

  • Download URL: useblysh-1.0.1.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for useblysh-1.0.1.tar.gz
Algorithm Hash digest
SHA256 d2e2f7dcbef9fc7bb8d76abd41605ca578ad1ec1567946c2651d32444d88c696
MD5 c879a3ea9f1fa0b2d48f9984d16317b6
BLAKE2b-256 4eb02e681d497bbf0a8a5d6c357991248820251bfcaac25d852550640417bfd8

See more details on using hashes here.

File details

Details for the file useblysh-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: useblysh-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for useblysh-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 42b94d5eb280bd4a1597bded3328ec4bc5c905e2094a3d6b8cdaaca10d9117cf
MD5 b9695c67d6ab74a24202ec5cb8ae507f
BLAKE2b-256 aa587e3151384d83490a7e68325c1be6fd23b0ed81e5ced2a980a8429d67a685

See more details on using hashes here.

Supported by

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