Code Monkey home page Code Monkey logo

django-thumbor's Introduction

django-thumbor

CI status on Travis CI Latest django-thumbor PyPI version Number of downloads for django-thumbor on PyPI Code coverage on Coveralls Dependency Status on Gemnasium

A django application to resize images using the thumbor service.

Usage

Both thumbor_url templatetag and the generate_url helper uses the same arguments as libthumbor, you can check the wiki for more info.

On templates:

{% load thumbor_tags %}
<img src="{% thumbor_url '/media/image.jpg' width=300 %}" width="300" />

Split filters with : (or use a list object):

{% load thumbor_tags %}
<img src="{% thumbor_url url filters='watermark(http://domain.com/watermark.png,-10,-10,20):brightness(10)' %}" />
<img src="{% thumbor_url url filters=filter_list %}" />

On code:

from django_thumbor import generate_url
resized = generate_url("/media/image.jpg", width=300)

There is an extra parameter to specify a custom server to be used instead of settings.THUMBOR_SERVER.

On templates:

{% load thumbor_tags %}
<img src="{% thumbor_url '/media/image.jpg' thumbor_server='http://localhost:8888/foo' width=300 %}" width="300" />

On code:

from django_thumbor import generate_url
custom_server = "http://localhost:8888/foo"
resized = generate_url(
    "/media/image.jpg", thumbor_server=custom_server, width=300)

Installation

pip install django-thumbor

Configuration

Add the app to the INSTALLED_APPS:

INSTALLED_APPS = (
    # ...
    'django_thumbor',
)

Here are the default settings that you can override:

# The host serving the thumbor resized images
THUMBOR_SERVER = 'http://localhost:8888'

# The prefix for the host serving the original images
# This must be a resolvable address to allow thumbor to reach the images
THUMBOR_MEDIA_URL = 'http://localhost:8000/media'

# The same security key used in the thumbor service to
# match the URL construction
THUMBOR_SECURITY_KEY = 'MY_SECURE_KEY'

# Default arguments passed to the `generate_url` helper or
# the `thumbor_url` templatetag
THUMBOR_ARGUMENTS = {}

Contributing

Install

Fork, clone, create a virtualenv and run:

git clone git://github.com/ricobl/django-thumbor.git
mkvirtualenv django-thumbor
make install

Test

Add tests on testproject/tests, add code and run:

make test

Authors

@ricobl @avelino @Starou

django-thumbor's People

Contributors

avelino avatar ricobl avatar starou avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.