All Projects → rouk1 → django-image-renderer

rouk1 / django-image-renderer

Licence: WTFPL License
render images in many sizes

Programming Languages

python
139335 projects - #7 most used programming language
CSS
56736 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to django-image-renderer

ngx-cropper
An Angular image plugin, includes upload, cropper, save to server.
Stars: ✭ 14 (+16.67%)
Mutual labels:  crop
image-php
很多PHP框架竟然没有图片设定宽高居中剪裁的功能,比如CodeIgniter,所以我自己封装了一个图片处理类:可设定宽高居中剪裁、设定宽高等比缩放、创建缩略图
Stars: ✭ 17 (+41.67%)
Mutual labels:  crop
Lassi-Android
All in 1 picker library for android.
Stars: ✭ 108 (+800%)
Mutual labels:  crop
Krishi-Seva
A Farmer friendly app and website to give crop recommendations according to soil samples collected by ICAR and the weather forecast.
Stars: ✭ 22 (+83.33%)
Mutual labels:  crop
tinycrop
Pure JavaScript image crop library
Stars: ✭ 62 (+416.67%)
Mutual labels:  crop
1click-webpage-screenshot
Entire page Screenshot extension for Google Chrome. I'm developing open source extension for Google Chrome. All extension are free for use. Let's make Chrome great again!
Stars: ✭ 432 (+3500%)
Mutual labels:  crop
Google-Images-Search
[PYTHON] Search for image using Google Custom Search API and resize & crop afterwards
Stars: ✭ 121 (+908.33%)
Mutual labels:  crop
FunCrop
Video Split Effect: a lots of transition effect in a video.
Stars: ✭ 42 (+250%)
Mutual labels:  crop
imgwizard
Simple server for On-the-Fly image processing in Go
Stars: ✭ 51 (+325%)
Mutual labels:  crop
tiny
compress data for better performance
Stars: ✭ 21 (+75%)
Mutual labels:  crop
krop
A simple graphical tool to crop the pages of PDF files, written in Python/Qt
Stars: ✭ 88 (+633.33%)
Mutual labels:  crop
mpv-scripts
dynamic-crop.lua script for mpv player/lib.
Stars: ✭ 43 (+258.33%)
Mutual labels:  crop
sic
🦜 Accessible image processing and conversion from the terminal. Front-end for image-rs/image.
Stars: ✭ 96 (+700%)
Mutual labels:  crop
FotoKilof
GUI for ImageMagick
Stars: ✭ 114 (+850%)
Mutual labels:  crop
react-native-avatar-crop
Highly customisable <Crop /> component for React Native < 💅 >
Stars: ✭ 47 (+291.67%)
Mutual labels:  crop
vesdk-android-demo
VideoEditor SDK: A fully customizable video editor for your app.
Stars: ✭ 90 (+650%)
Mutual labels:  crop
Cropper
Android Library for cropping an image at ease.
Stars: ✭ 21 (+75%)
Mutual labels:  crop
downscale
Better image downscale with canvas.
Stars: ✭ 80 (+566.67%)
Mutual labels:  crop
ngx-image-editor
Awesome image editor for Angular 6
Stars: ✭ 74 (+516.67%)
Mutual labels:  crop
cropper
Bildbearbeitung im REDAXO-Medienpool: Zuschneiden, Drehen, Spiegeln.
Stars: ✭ 33 (+175%)
Mutual labels:  crop

Django image renderer

Build Status Coverage PyPI Version

Django image renderer is an app that will help you render images in many sizes (renditions). This can be really helpful for generating images size for different screens resolution (especially when targeting mobile).


Features

  • uses Pillow to resize images
  • uses Django's default_storage to let you play with whatever storage backend you'll need
  • uploaded image files named using uuid
  • rendition cached on disk
  • resize keeping original aspect ratio
  • crop if needed
  • simple widget for admin site

Quick start

Install the app.

pip install django-image-renderer

Add "renderer" to your INSTALLED_APPS setting like this:

settings.py

INSTALLED_APPS = (
    # your apps
    'renderer',
)

Include the renderer URL configuration in your project urls.py like this:

urls.py

url(r'^renderer/', include('renderer.urls', namespace='renderer')),

Run python manage.py migrate to create the renderer models.

Start the development server and visit http://localhost:8000/admin/ to create a MasterImage (you'll need the Admin app enabled).

Requirements

  • Python (2.7, 3.4, 3.5)
  • Django (1.7, 1.8, 1.9)

Usage

There is only one model in the app: MasterImage. With a MasterImage you can ask for renditions.

m = MasterImage.objects.first()

# get the master file's URL
m.get_master_url()
# or
m.get_rendition_url(0, 0)

# cache and return URL of a renditions that as 200 pixels width
# and height computed according to master's aspect ratio
url = m.get_rendition_url(200, 0)

# cache and return URL of a renditions that as 50 pixels height
# and width computed according to master's aspect ratio
url = m.get_rendition_url(0, 50)

If you ask for a size that do not fit master's aspect ration you'll receive a center cropped image.

You can also ask for a rendition in templates.

models.py

def index(request):
    m = MasterImage.objects.first()
    return render(request, 'demo/index.html', {
        'master': m,
    })

index.html

{% load renderer %}
...
{% rendition master 42 42 %}
...
{% rendition_url 42 42 %}
...

This will render as:

<img src="/media/img/0fb34de8-9d83-456a-828b-72ab21f8ebab_42x42.png" width="42" height="42" alt="">
...
/media/img/0fb34de8-9d83-456a-828b-72ab21f8ebab_42x42.png
...

When using MasterImage in your model you may need a widget who provides a preview for you image. For convenience a mixin is provided.

models.py

from django.db import models

class DemoModel(models.Model):
    master = models.ForeignKey('renderer.MasterImage')

admin.py

from demo.models import DemoModel
from django.contrib import admin
from renderer.widgets import MasterImageAdminMixin

@admin.register(DemoModel)
class DemoModelAdmin(MasterImageAdminMixin, admin.ModelAdmin):
    fields = ('master', )

Sample project

A sample project is available in the sample folder. Test it as an usual Django project:

virtualenv --no-site-packages venv
source venv/bin/activate
pip install -r requirements.txt
python sample/manage.py migrate
python sample/manage.py createsuperuser
python sample/manage.py runserver

It' also deployed at http://django-image-renderer.herokuapp.com/.

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].