Datasette plugin that renders binary blob images using data-uris
Project description
datasette-render-images
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
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 Distribution
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 384ea7b7acad8f015df246d2847d5f9d4e0b98dbb20bb011c9722d27f1f8c8d4 |
|
MD5 | 1b258632645f6e91ea162808d98d12c7 |
|
BLAKE2b-256 | 5dfbb81a7b969764620f35f5a9720a0fe69bedde34e18bc3dd6382e5e9aff6cf |
File details
Details for the file datasette_render_images-0.4-py3-none-any.whl
.
File metadata
- Download URL: datasette_render_images-0.4-py3-none-any.whl
- Upload date:
- Size: 3.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 337a5871a126637d706a7a8db4b2939ff6fa4f337a9e8aaeb476aca3bdb8835b |
|
MD5 | 687d5f0816c2eee93bcf883560f9bc72 |
|
BLAKE2b-256 | 9a4dfcec9f11d81310772543a7709983a712295bfb69c9bf2b57dedd5ea9a160 |