All Projects → chhantyal → sorl-thumbnail-async

chhantyal / sorl-thumbnail-async

Licence: BSD-3-Clause license
Asynchronous thumbnailing app in django with remote storages like S3

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to sorl-thumbnail-async

Django-CRM-Project
Django CRM Project - Youtube Tutorial
Stars: ✭ 108 (+414.29%)
Mutual labels:  django-application
mubapp
MUB is a multi-user blog web app using the Python-Django infrastructure.
Stars: ✭ 24 (+14.29%)
Mutual labels:  django-application
django-lock-tokens
A Django application that provides a locking mechanism to prevent concurrency editing.
Stars: ✭ 19 (-9.52%)
Mutual labels:  django-application
django-letsagree
A Django application that associates Groups with Terms requiring consent from logged in members.
Stars: ✭ 12 (-42.86%)
Mutual labels:  django-application
PyShop
PyShop is an online Python Ecommerce website built with Django, SQLite and Bootstrap. A simple and lightweight ecommerce app easily deployable anywhere anytime with modules developed upon the inbuilt django admin.
Stars: ✭ 17 (-19.05%)
Mutual labels:  django-application
wagtailmath
Beautiful equations in your StreamField content
Stars: ✭ 27 (+28.57%)
Mutual labels:  django-application
soak-your-brain-elearning-app
An e-learning platform built in python (django)
Stars: ✭ 18 (-14.29%)
Mutual labels:  django-application
g3w-admin
Server module for G3W-SUITE
Stars: ✭ 24 (+14.29%)
Mutual labels:  django-application
Django-Verify-Email
A two-step verification for new accounts by verifying email.
Stars: ✭ 51 (+142.86%)
Mutual labels:  django-application
python-web-dev-21-2
Material for "Web Development in Python with Django" using Django 2.1, published as a Pearson LiveLesson on Safari Books Online
Stars: ✭ 38 (+80.95%)
Mutual labels:  django-application
Deep-learning-model-deploy-with-django
Serving a keras model (neural networks) in a website with the python Django-REST framework.
Stars: ✭ 76 (+261.9%)
Mutual labels:  django-application
django-survey
A django survey app that can export results as CSV or PDF using your native language.
Stars: ✭ 178 (+747.62%)
Mutual labels:  django-application
django-siteforms
Django reusable app to simplify form construction
Stars: ✭ 15 (-28.57%)
Mutual labels:  django-application
django-proxypay
Django Proxypay is a Django Framework application/library that facilitates the integration of your Django project with the Proxypay API.
Stars: ✭ 14 (-33.33%)
Mutual labels:  django-application
django-renderpdf
📄 A Django app to render django templates as PDF files.
Stars: ✭ 37 (+76.19%)
Mutual labels:  django-application
xlsx over web
Django开发的excel表格展示系统,将本地xlsx文件导入到数据库,显示到JS页面 online excel manage with django
Stars: ✭ 27 (+28.57%)
Mutual labels:  django-application
google-form-clone
Clone of Google forms built using Django and Javascript
Stars: ✭ 112 (+433.33%)
Mutual labels:  django-application
PyQuotes
PyQuotes is a Django-based web application and REST API. That will allow you to launch an online quotes service.
Stars: ✭ 23 (+9.52%)
Mutual labels:  django-application
django-extra-field-validation
Extends the Django model with required, conditional, and optional field validation.
Stars: ✭ 18 (-14.29%)
Mutual labels:  django-application
acme2certifier
library implementing ACME server functionality
Stars: ✭ 62 (+195.24%)
Mutual labels:  django-application

sorl-thumbnail-async

Asynchronous thumbnailing app in django with remote storages like S3. This is modifications of some parts of sorl-thumbnail, which is a bit slow when used with remote storages.

  • Celery is used to create thumbnail asynchronously.
  • Thumbnails are pregenerated and cached.
  • Thumbnail sizes and options are specified in one place (your settings file).

Install

pip install sorl-thumbnail-async

Add 'thumbnail' to your INSTALLED_APPS.

Dependencies

pip install django

pip install django-celery

pip install pillow

pip install sorl-thumbnail

Usage

In your settings.py add an option called THUMBNAIL_OPTIONS_DICT, defining all your thumbnail sizes:

THUMBNAIL_OPTIONS_DICT = {
        'small': {
                'geometry': '140x140',
                'crop': 'center'
        }
    }

In your models, use thumbnail.models.AsyncThumbnailMixin as a baseclass. Make sure that your model inherits from AsyncThumbnailMixin first. This will call celery task on save(), and create one or more thumbnails from the specified image field. Use class variable image_field_name to configure the field that contains the image. Defaults to picture.

Example:

from django.db import models

from sorl import thumbnail
from thumbnail.models import AsyncThumbnailMixin


class Book(AsyncThumbnailMixin, models.Model):
    image_field_name = 'cover_image'

	title = models.CharField(blank=False, max_length=255, db_index=True)
    cover_image = thumbnail.ImageField(upload_to='books/')

In templates:

{% load thumbnail_tags %}
{% thumbnail book.cover_image small as im %}
<img src"{{ im.url }}">
{% endthumbnail %}

In python code:

from thumbnail import get_thumbnail

book = Book.objects.get(title='Life of Pi')
thumbnail_url = get_thumbnail(book.cover_image, 'small').url

Settings

You can add as many sizes and option as needed. It is a python dictionary.

THUMBNAIL_OPTIONS_DICT = {
        'small': {
                'geometry': '140x140',
                'crop': 'center'
        }
    }

NOTE: sorl-thumbnail-async registers its own THUMBNAIL_BACKEND:

THUMBNAIL_BACKEND = 'sorl-thumbnail-async.thumbnail.backend.AsyncThumbnailBackend'

Bitdeli Badge

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].