Skip to main content

Resizes image origin to specified size.

Project description

https://travis-ci.org/un1t/django-resized.svg?branch=master

Resizes image origin to specified size. Compatible with sorl-thumbnail.

Features

  • Tested on Django 1.8, 1.9, 1.10 and 1.11

  • Python 3 support

Installation

pip install django-resized

Configuration (optional)

settings.py

DJANGORESIZED_DEFAULT_SIZE = [1920, 1080]
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

Usage

models.py

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, 100], crop=['middle', 'center'], upload_to='whatever')
    image4 = ResizedImageField(size=[500, 300], quality=75, upload_to='whatever')
    image5 = ResizedImageField(size=[500, 300], upload_to='whatever', force_format='PNG')

Options

  • size - max width and height, for example [640, 480]

  • crop - resize and crop. [‘top’, ‘left’] - top left corner, [‘middle’, ‘center’] is center cropping, [‘bottom’, ‘right’] - crop right bottom corner.

  • quality - quality of resized image 1..100

  • keep_meta - keep EXIF and other meta data, default True

  • force_format - force the format of the resized image, available formats are the one supported by pillow, default to None

How to run tests

pip install tox
tox

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-resized-0.3.10.tar.gz (4.0 kB view details)

Uploaded Source

File details

Details for the file django-resized-0.3.10.tar.gz.

File metadata

  • Download URL: django-resized-0.3.10.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/2.7

File hashes

Hashes for django-resized-0.3.10.tar.gz
Algorithm Hash digest
SHA256 7b4b9c43bb74a140cd098c892fe7570a7fe99188de4975a0086c753e4cfe44a2
MD5 fdad29e93d07e4738017c235a0ef7c24
BLAKE2b-256 79170de96633d40caa8e0ef5c519dddcb87b2d1a248dbba96af48e9294a667f4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page