.. image:: https://github.com/un1t/django-resized/actions/workflows/python-app.yml/badge.svg :target: https://github.com/un1t/django-resized/actions/workflows/python-app.yml
Resizes image origin to specified size. Compatible with sorl-thumbnail.
.. code-block:: bash
pip install django-resized
settings.py
.. code-block:: python
DJANGORESIZED_DEFAULT_SIZE = [1920, 1080]
DJANGORESIZED_DEFAULT_SCALE = 0.5
DJANGORESIZED_DEFAULT_QUALITY = 75
DJANGORESIZED_DEFAULT_KEEP_META = True
DJANGORESIZED_DEFAULT_FORCE_FORMAT = 'JPEG'
DJANGORESIZED_DEFAULT_FORMAT_EXTENSIONS = {'JPEG': ".jpg"}
DJANGORESIZED_DEFAULT_NORMALIZE_ROTATION = True
models.py
.. code-block:: python
from django_resized import ResizedImageField
class MyModel(models.Model):
...
image1 = ResizedImageField(size=[500, 300], upload_to='whatever')
image2 = ResizedImageField(size=[100, 100], crop=['top', 'left'], upload_to='whatever')
image3 = ResizedImageField(size=[100, 150], crop=['middle', 'center'], upload_to='whatever')
image4 = ResizedImageField(scale=0.5, quality=75, upload_to='whatever')
image5 = ResizedImageField(size=None, upload_to='whatever', force_format='PNG')
image6 = ResizedImageField(size=[100, None], upload_to='whatever')
pillow <http://pillow.readthedocs.io/en/3.4.x/handbook/image-file-formats.html>
_, default to None.. code-block:: bash
pip install tox
tox
Version | Tag | Published |
---|---|---|
1.0.2 | 8mos ago | |
1.0.1 | 9mos ago | |
1.0.0 | 1yr ago | |
0.3.11 | 3yrs ago |