django-thummer’s documentation

A website screenshot and thumbnailing app for Django. Uses firefox, selenium, sorl-thumbnail, and celery.

Contents:

Setup

Requirements

django-thummer requires Firefox. On Debian/Ubuntu systems this can be installed using:

sudo apt-get install firefox

geckodriver is also required. This can be downloaded from the geckodriver releases page, and extracted to somewhere on the system path, e.g. /usr/local/bin.

Installation

django-thummer can be installed to your Python environment using pip:

python -m pip install django-thummer

Then add thummer to INSTALLED_APPS in your Django settings file.

Using Celery for background thumbnail capture

It is highly recommended to use Celery for background thumbnail capture. By default, django-thummer will automatically use Celery if it is available.

Configuring celery can be tricky, and you should carefully the celery documentation.

Basic API Example

from thummer.utils import get_thumbnail

thumbnail = get_thumbnail('http://www.example.com/', '400x400')

Template Tag

{% load thummer %}

{% thummer "http://www.example.com/" "400x400" as thumb %}
<img src="{{ thumb.url }}" alt="" />
{% endthummer %}

Reference:

Settings

THUMMER_PLACEHOLDER_DEFAULTS

Default: {'crop': 'center', 'upscale': False, 'format': 'PNG'} (Dictionary)

A keywords dictionary passed to sorl.thumbnail when generating placeholder thumbnails.

THUMMER_PLACEHOLDER_PATH

Default: 'thummer/placeholder.png' (String)

The path to the placeholder image in your staticfiles storage.

THUMMER_QUEUE_SNAPSHOTS

Default: True (Boolean) if 'djcelery' is in Django’s 'INSTALLED_APPS' setting.

Determine if thumbnail generation should be queued for background processing using django-celery (recommended).

THUMMER_SNAPSHOTS_VALID_FOR

Default: dateutil.relativedelta.relativedelta(months=+3) (A dateutil relativedelta of 3 months)

The period of time that a thumbnail snapshot of a url is valid for, before a new thumbnail is generated.

THUMMER_STORAGE

Default: django.core.files.storage.default_storage (Django’s configured default storage)

Storage instance to use for thumbnail media.

THUMMER_THUMBNAIL_DEFAULTS

Default: {'crop': 'left top', 'upscale': False, 'format': 'JPEG'} (Dictionary)

A keywords dictionary passed to sorl.thumbnail when generating thumbnails.

THUMMER_UPLOAD_PATH

Default: 'thummer/snapshots' (String)

The path prefix to store thumbnails under in THUMMER_STORAGE.

Credits

Special thanks to the sorl-thumbnail, selenium, and celery, projects. Thanks also to the blog posts which originally got me thinking about the project:

Indices and tables