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 useblysh

🚀 Simple Examples

1. Generate Hash (Python)

Generate hashes on your server using the Python library.

from PIL import Image
from useblysh import encode

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

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

2. Frontend Decoding (React)

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.

import { ImageHash } from 'useblysh'; 
 
<ImageHash 
  hash={storedHash}        // The short string from your Python backend
  src={imageUrl}          // The real high-quality image URL 
  className="w-full h-64 rounded-xl" 
/>

💡 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.2.tar.gz (4.7 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.2-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: useblysh-1.0.2.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for useblysh-1.0.2.tar.gz
Algorithm Hash digest
SHA256 eb98682409e2cdc396b7edc12ec3398eab837e1bf6a4139889056cf8917945c9
MD5 5be4710fcfbe876d314c6e8fca34b695
BLAKE2b-256 524e881ca0159d21b33c45d89998e151c44ecdca382e26de28b89ffa48cebeb0

See more details on using hashes here.

Provenance

The following attestation bundles were made for useblysh-1.0.2.tar.gz:

Publisher: useblysh-py.yml on R1SH4BH81/Blysh

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: useblysh-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for useblysh-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f62b2f30196c5fe8bd5d476b156691a93b9657de5f852df8966f46fc5df4ba3d
MD5 d787ce1e688a73bc9422b833fffd11c7
BLAKE2b-256 6447d95471646a84f3be460f540a8eab22080bce6b6ecde2b7c693f61d0402d2

See more details on using hashes here.

Provenance

The following attestation bundles were made for useblysh-1.0.2-py3-none-any.whl:

Publisher: useblysh-py.yml on R1SH4BH81/Blysh

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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