Skip to main content
Join the official 2020 Python Developers SurveyStart the survey!

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.

Files for datasette-render-images, version 0.3.2
Filename, size File type Python version Upload date Hashes
Filename, size datasette_render_images-0.3.2-py3-none-any.whl (3.0 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size datasette-render-images-0.3.2.tar.gz (2.7 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page