Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add travis support #215

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -4,4 +4,5 @@ build
docs/_build
.tox/
*.egg
*.pyc
reports/*
21 changes: 21 additions & 0 deletions .travis.yml
@@ -0,0 +1,21 @@
language: python

python:
- "2.6"
- "2.7"

env:
- PYTHONPATH=$PYTHONPATH:$PWD DJANGO_VERSION=1.4.5
- PYTHONPATH=$PYTHONPATH:$PWD DJANGO_VERSION=1.5.1

before_install:
- sudo apt-get build-dep python-imaging
- sudo ln -s /usr/lib/`uname -i`-linux-gnu/libfreetype.so /usr/lib/
- sudo ln -s /usr/lib/`uname -i`-linux-gnu/libjpeg.so /usr/lib/
- sudo ln -s /usr/lib/`uname -i`-linux-gnu/libz.so /usr/lib/

install:
- pip install --use-mirrors PIL Django==$DJANGO_VERSION

script:
- django-admin.py test easy_thumbnails --settings=easy_thumbnails.test_settings
267 changes: 135 additions & 132 deletions README.rst
@@ -1,133 +1,136 @@
===============
Easy Thumbnails
===============

A powerful, yet easy to implement thumbnailing application for Django.

Below is a quick summary of usage. For more comprehensive information, view the
`full documentation`__ online or the peruse the project's ``docs`` directory.

__ http://easy-thumbnails.readthedocs.org/en/latest/index.html


Installation
============

Run ``pip install easy-thumbnails``, or for the `in-development version`__
run ``pip install easy-thumbnails==dev``.

__ https://github.com/SmileyChris/easy-thumbnails/tarball/master#egg=easy_thumbnails-dev

Add ``easy_thumbnails`` to your ``INSTALLED_APPS`` setting::

INSTALLED_APPS = (
...
'easy_thumbnails',
)

If you have South installed then run ``manage.py migrate easy_thumbnails``,
otherwise just run ``manage.py syncdb``.


Example usage
=============

Thumbnail options can be predefined in ``settings.THUMBNAIL_ALIASES`` or just
specified in the template or Python code when run.

Using a predefined alias
------------------------

Given the following setting::

THUMBNAIL_ALIASES = {
'': {
'avatar': {'size': (50, 50), 'crop': True},
},
}

Template::

{% load thumbnail %}
<img src="{{ profile.photo|thumbnail_url:'avatar' }}" alt="" />

Python::

from easy_thumbnails.files import get_thumbnailer
thumb_url = get_thumbnailer(profile.photo)['avatar'].url

Manually specifying size / options
----------------------------------

Template::

{% load thumbnail %}
<img src="{% thumbnail profile.photo 50x50 crop %}" alt="" />

Python::

from easy_thumbnails.files import get_thumbnailer
options = {'size': (100, 100), 'crop': True}
thumb_url = get_thumbnailer(profile.photo).get_thumbnail(options).url


Fields
======

You can use ``ThumbnailerImageField`` (or ``ThumbnailerFileField``) for easier
access to retrieve or generate thumbnail images.

For example::

from easy_thumbnails.fields import ThumbnailerImageField

class Profile(models.Model):
user = models.OneToOneField('auth.User')
photo = ThumbnailerImageField(upload_to='photos', blank=True)

Accessing the field's predefined alias in a template::

{% load thumbnail %}
<img src="{{ profile.photo.avatar.url }}" alt="" />

Accessing the field's predefined alias in Python code::

thumb_url = profile.photo['avatar'].url


Thumbnail options
=================

``crop``
--------

Before scaling the image down to fit within the ``size`` bounds, it first cuts
the edges of the image to match the requested aspect ratio.

Use ``crop="smart"`` to try to keep the most interesting part of the image,

Use ``crop="0,10"`` to crop from the left edge and a 10% offset from the
top edge. Crop from a single edge by leaving dimension empty (e.g.
``crop=",0"``). Offset from the right / bottom by using negative numbers
(e.g., crop="-0,-10").

Often used with the ``upscale`` option, which will allow enlarging of the image
during scaling.

``quality=XX``
--------------

Changes the quality of the output JPEG thumbnail. Defaults to ``85``.

In Python code, this is given as a separate option to the ``get_thumbnail``
method rather than just alter the other

Other options
-------------

Valid thumbnail options are determined by the "thumbnail processors" installed.

See the `reference documentation`__ for a complete list of options provided by
the default thumbnail processors.

Easy Thumbnails
===============

.. image:: https://secure.travis-ci.org/SmileyChris/easy-thumbnails.png?branch=master
:alt: Build Status
:target: http://travis-ci.org/SmileyChris/easy-thumbnails

A powerful, yet easy to implement thumbnailing application for Django.

Below is a quick summary of usage. For more comprehensive information, view the
`full documentation`__ online or the peruse the project's ``docs`` directory.

__ http://easy-thumbnails.readthedocs.org/en/latest/index.html


Installation
============

Run ``pip install easy-thumbnails``, or for the `in-development version`__
run ``pip install easy-thumbnails==dev``.

__ https://github.com/SmileyChris/easy-thumbnails/tarball/master#egg=easy_thumbnails-dev

Add ``easy_thumbnails`` to your ``INSTALLED_APPS`` setting::

INSTALLED_APPS = (
...
'easy_thumbnails',
)

If you have South installed then run ``manage.py migrate easy_thumbnails``,
otherwise just run ``manage.py syncdb``.


Example usage
=============

Thumbnail options can be predefined in ``settings.THUMBNAIL_ALIASES`` or just
specified in the template or Python code when run.

Using a predefined alias
------------------------

Given the following setting::

THUMBNAIL_ALIASES = {
'': {
'avatar': {'size': (50, 50), 'crop': True},
},
}

Template::

{% load thumbnail %}
<img src="{{ profile.photo|thumbnail_url:'avatar' }}" alt="" />

Python::

from easy_thumbnails.files import get_thumbnailer
thumb_url = get_thumbnailer(profile.photo)['avatar'].url

Manually specifying size / options
----------------------------------

Template::

{% load thumbnail %}
<img src="{% thumbnail profile.photo 50x50 crop %}" alt="" />

Python::

from easy_thumbnails.files import get_thumbnailer
options = {'size': (100, 100), 'crop': True}
thumb_url = get_thumbnailer(profile.photo).get_thumbnail(options).url


Fields
======

You can use ``ThumbnailerImageField`` (or ``ThumbnailerFileField``) for easier
access to retrieve or generate thumbnail images.

For example::

from easy_thumbnails.fields import ThumbnailerImageField

class Profile(models.Model):
user = models.OneToOneField('auth.User')
photo = ThumbnailerImageField(upload_to='photos', blank=True)

Accessing the field's predefined alias in a template::

{% load thumbnail %}
<img src="{{ profile.photo.avatar.url }}" alt="" />

Accessing the field's predefined alias in Python code::

thumb_url = profile.photo['avatar'].url


Thumbnail options
=================

``crop``
--------

Before scaling the image down to fit within the ``size`` bounds, it first cuts
the edges of the image to match the requested aspect ratio.

Use ``crop="smart"`` to try to keep the most interesting part of the image,

Use ``crop="0,10"`` to crop from the left edge and a 10% offset from the
top edge. Crop from a single edge by leaving dimension empty (e.g.
``crop=",0"``). Offset from the right / bottom by using negative numbers
(e.g., crop="-0,-10").

Often used with the ``upscale`` option, which will allow enlarging of the image
during scaling.

``quality=XX``
--------------

Changes the quality of the output JPEG thumbnail. Defaults to ``85``.

In Python code, this is given as a separate option to the ``get_thumbnail``
method rather than just alter the other

Other options
-------------

Valid thumbnail options are determined by the "thumbnail processors" installed.

See the `reference documentation`__ for a complete list of options provided by
the default thumbnail processors.

__ http://easy-thumbnails.readthedocs.org/en/latest/ref/processors/
2 changes: 2 additions & 0 deletions easy_thumbnails/test_settings.py
Expand Up @@ -25,3 +25,5 @@

# This is only needed for the 1.4.X test environment
USE_TZ = True

SECRET_KEY = 'test'