Skip to content

Commit

Permalink
Merge branch 'master' into keep-icc-master
Browse files Browse the repository at this point in the history
  • Loading branch information
siovene authored Dec 4, 2022
2 parents 09174c9 + 66da220 commit 92d7f58
Show file tree
Hide file tree
Showing 39 changed files with 840 additions and 321 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Publish easy-thumbnails

on:
push:
tags:
- '*'

jobs:
publish:
name: "Publish release"
runs-on: "ubuntu-latest"

environment:
name: deploy

strategy:
matrix:
python-version: ["3.9"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install build --user
- name: Build 🐍 Python 📦 Package
run: python -m build --sdist --wheel --outdir dist/
- name: Publish 🐍 Python 📦 Package to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.PYPI_API_TOKEN_EASY_THUMBNAILS }}
31 changes: 31 additions & 0 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Python CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:

runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10']

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox tox-gh-actions
- name: Run tests
run: tox
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ docs/_build
*.egg
*.pyc
reports/*
.python-version
5 changes: 5 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
version: 2

python:
install:
- requirements: docs/requirements.txt
8 changes: 0 additions & 8 deletions .travis.yml

This file was deleted.

40 changes: 40 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,44 @@
Changes
=======

2.8.3 (2022-08-02)
------------------
* Fix regression in library detection introduced in version 2.8.2.


2.8.2 (2022-07-31)
------------------
* Installation of easy-thumbnails now optionally depends on the reportlab library.


2.8.1 (2022-01-20)
------------------

* Add support for Django 4.
* New ``THUMBNAIL_IMAGE_SAVE_OPTIONS`` setting.
* Fix #587: Uploading SVG Images to S3 storage.


2.8.0 (2021-11-03)
------------------

* Add support for thumbnailing SVG images. This is done by adding an emulation layer named VIL,
which aims to be compatible with PIL. All thumbnailing operations, such as scaling and cropping
behave like pixel images.
* Remove configuration directives ``THUMBNAIL_HIGH_RESOLUTION`` and ``THUMBNAIL_HIGHRES_INFIX``
from easy-thumbnails setting directives.


2.7.2 (2021-10-17)
------------------

* Add support for Django 3.2 and Python-3.10.
* Fix #563: Do not close image after loading content.
* In management command ``thumbnail_cleanup``, replace ``print``-statements
against ``stdout.write``.
* Use Python format strings whereever possible.


2.7.1 (2020-11-23)
------------------

Expand All @@ -15,11 +53,13 @@ Changes
* Drop support for Django < 1.11
* Drop support for Django 2.0, 2.1


2.6.0 (2019-02-03)
------------------

* Added testing for Django 2.2 (no code changes required).


2.5.0 (2017-10-31)
------------------

Expand Down
68 changes: 55 additions & 13 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,49 @@ Easy Thumbnails
.. image:: https://img.shields.io/pypi/v/easy-thumbnails.svg
:target: https://pypi.python.org/pypi/easy-thumbnails/

.. image:: https://secure.travis-ci.org/SmileyChris/easy-thumbnails.svg?branch=master
.. image:: https://github.com/SmileyChris/easy-thumbnails/actions/workflows/python.yml/badge.svg
:alt: Build Status
:target: http://travis-ci.org/SmileyChris/easy-thumbnails
:target: https://github.com/SmileyChris/easy-thumbnails/actions/workflows/python.yml


A powerful, yet easy to implement thumbnailing application for Django 1.11+
A powerful, yet easy to implement thumbnailing application for Django 2.2+

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


Breaking News
=============

Version 2.8.0 adds support for thumbnailing SVG images when installed with the ``[svg]`` extra.

Of course it doesn't make sense to thumbnail SVG images, because being in vector format they can
scale to any size without quality of loss. However, users of easy-thumbnails may want to upload and
use SVG images just as if they would be PNG, GIF or JPEG. They don't necessarily care about the
format and definitely don't want to convert them to a pixel based format. What they want is to reuse
their templates with the templatetag thumbnail and scale and crop the images to whatever their
`<img src="..." width="..." height="...">` has been prepared for.

This is done by adding an emulation layer named VIL, which aims to be compatible with the
`PIL <https://python-pillow.org/>`_ library. All thumbnailing operations, such as scaling and
cropping behave like pixel based images. The final filesize of such thumbnailed SVG images doesn't
of course change, but their width/height and bounding box may be adjusted to reflect the desired
size of the thumbnailed image.

.. note:: This feature is new and experimental, hence feedback about its proper functioning in
third parts applications is highly appreciated.


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

Run ``pip install easy-thumbnails``.

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

.. code-block:: python
INSTALLED_APPS = (
...
Expand All @@ -42,33 +66,43 @@ specified in the template or Python code when run.
Using a predefined alias
------------------------

Given the following setting::
Given the following setting:

.. code-block:: python
THUMBNAIL_ALIASES = {
'': {
'avatar': {'size': (50, 50), 'crop': True},
},
}
Template::
Template:

.. code-block:: html+django

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

Python::
Python:

.. code-block:: python
from easy_thumbnails.files import get_thumbnailer
thumb_url = get_thumbnailer(profile.photo)['avatar'].url
Manually specifying size / options
----------------------------------

Template::
Template:

.. code-block:: html+django

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

Python::
Python:

.. code-block:: python
from easy_thumbnails.files import get_thumbnailer
options = {'size': (100, 100), 'crop': True}
Expand All @@ -80,7 +114,9 @@ Using in combination with other thumbnailers
Alternatively, you load the templatetags by {% load easy_thumbnails_tags %}
instead of traditional {% load thumbnail %}. It's especially useful in
projects that do make use of multiple thumbnailer libraries that use the
same name (`thumbnail`) for the templatetag module::
same name (`thumbnail`) for the templatetag module:

.. code-block:: html+django

{% load easy_thumbnails_tags %}
<img src="{% thumbnail profile.photo 50x50 crop %}" alt="" />
Expand All @@ -91,20 +127,26 @@ Fields
You can use ``ThumbnailerImageField`` (or ``ThumbnailerField``) for easier
access to retrieve or generate thumbnail images.

For example::
For example:

.. code-block:: python
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::
Accessing the field's predefined alias in a template:

.. code-block:: html+django

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

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

.. code-block:: python
thumb_url = profile.photo['avatar'].url
Expand Down
20 changes: 9 additions & 11 deletions TESTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@ Testing
1. Install tox (``pip install tox``)
2. Run ``tox``

If you want to test against other versions of Python then you might need to
install them, too. Here's a quick log for installing them in Ubuntu (probably
just as relevant for Debian)::
To test against other versions of Python, the recommended way is to ``pip
install tox-pyenv`` and install each version in pyenv that you want to test
against.

sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install pythonX.Y pythonX.Y-dev
Run ``tox local <versions>`` to make them available when running tox.

sudo apt-get install build-essential python-dev python3-dev
sudo apt-get install libjpeg8-dev zlib1g-dev
pytest
------

For Ubuntu >=16.04, you'll also want::

sudo apt-get install python3.4 python3.4-dev
Assuming you're just wanting to test the current development version against
your virtualenv setup, you can alternatively just ``pip install pytest-django``
and run ``pytest``.
5 changes: 1 addition & 4 deletions docs/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
Installation
============

Before installing easy-thumbnails, you'll obviously need to have copy of
Django installed. For the |version| release, both Django 1.4 and Django 1.7 or
above is supported.

By default, all of the image manipulation is handled by the
`Python Imaging Library`__ (a.k.a. PIL), so you'll probably want that
installed too.
Expand All @@ -24,6 +20,7 @@ Simply type::

pip install easy-thumbnails


Manual installation
-------------------

Expand Down
26 changes: 26 additions & 0 deletions docs/ref/svg.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
===============================
Scalable Vector Graphic Support
===============================

Scalable Vector Graphics (SVG) is an XML-based vector image format for two-dimensional graphics with support for
interactivity and animation. The SVG specification is an open standard developed by the World Wide Web Consortium (W3C).

Thumbnailing vector graphic images doesn't really make sense, because being in vector format they can scale to any size
without any quality of loss. However, users of **easy-thumbnails** may want to upload and use SVG images just as if
they would be in PNG, GIF or JPEG format. End users don't necessarily care about the format and definitely don't want
to convert them to a pixel based format. What they want is to reuse their templates with the templatetag
``{% thumbnail image ... as thumb %}``, and scale and crop the images to whatever the
element tag ``<img src="{{ thumb.url }}" width="..." height="...">`` has been prepared for.

This is done by adding an emulation layer named VIL, which aims to be compatible with PIL. All thumbnailing operations,
such as scaling and cropping behave like their pixel based counterparts. The content and final filesize of such
thumbnailed SVG images doesn't of course change, but their width/height and bounding box may be adjusted to reflect the
desired size of the thumbnailed image. Therefore, "thumbnailed" SVG images are stored side by side with their original
images and hence can be used by third-party apps such as
`django-filer<https://django-filer.readthedocs.io/en/latest/>`_ without modification.

Since easy-thumbnails version 2.8, you can therefore use an SVG image, just as you would use any other image.

This requires easy-thumbnails to have been installed with the ``[svg]`` extra enabled.

Cropping an SVG image works as expected. Filtering an SVG image will however not work.
2 changes: 1 addition & 1 deletion docs/ref/webp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ In the future, Easy Thumbnails might support WebP natively. This however means t
be usable as ``<img ...>`` -tag, supported by all browsers, and fully integrated into tools
such as django-filer_.

Until that happens, I reccomend to proceed with the workarround described here.
Until that happens, I recommend to proceed with the workarround described here.

.. _django-filer: https://django-filer.readthedocs.io/en/latest/
1 change: 1 addition & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docutils<0.18
Loading

0 comments on commit 92d7f58

Please sign in to comment.