Skip to main content

Datasette plugin that renders binary blob images using data-uris

Project description

datasette-render-images

PyPI Changelog Tests License

A Datasette plugin that renders binary blob images with data-uris, using the render_cell() plugin hook.

Installation

Install this plugin in the same environment as Datasette.

$ pip install datasette-render-images

Usage

If a database row contains binary image data (PNG, GIF or JPEG), this plugin will detect that it is an image (using the imghdr module and render that cell using an <img src="data:image/png;base64,..."> element.

Here's a demo of the plugin in action.

Creating a compatible database table

You can use the sqlite-utils insert-files command to insert image files into a database table:

$ pip install sqlite-utils
$ sqlite-utils insert-files gifs.db images *.gif

See Fun with binary data and SQLite for more on this tool.

Configuration

By default the plugin will only render images that are smaller than 100KB. You can adjust this limit using the size_limit plugin configuration option - for example, to increase the limit to 1MB (1000000 bytes) use the following in metadata.json:

{
    "plugins": {
        "datasette-render-images": {
            "size_limit": 1000000
        }
    }
}

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

datasette-render-images-0.4.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

datasette_render_images-0.4-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file datasette-render-images-0.4.tar.gz.

File metadata

  • Download URL: datasette-render-images-0.4.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for datasette-render-images-0.4.tar.gz
Algorithm Hash digest
SHA256 384ea7b7acad8f015df246d2847d5f9d4e0b98dbb20bb011c9722d27f1f8c8d4
MD5 1b258632645f6e91ea162808d98d12c7
BLAKE2b-256 5dfbb81a7b969764620f35f5a9720a0fe69bedde34e18bc3dd6382e5e9aff6cf

See more details on using hashes here.

File details

Details for the file datasette_render_images-0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for datasette_render_images-0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 337a5871a126637d706a7a8db4b2939ff6fa4f337a9e8aaeb476aca3bdb8835b
MD5 687d5f0816c2eee93bcf883560f9bc72
BLAKE2b-256 9a4dfcec9f11d81310772543a7709983a712295bfb69c9bf2b57dedd5ea9a160

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