Skip to main content

Resizes image origin to specified size.

Project description

# django-resized

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

## Installation

pip install django-resized

# Configuration (optional)

settings.py

DJANGORESIZED_DEFAULT_SIZE = [1920, 1080] DJANGORESIZED_DEFAULT_QUALITY = 75

## 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’)

### 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

## How to run tests

pip install -r django_resized/testapp/requirements.txt ./runtests.py

## Move to 0.3.x

If you use South, you may receive such error:

TypeError: __init__() got an unexpected keyword argument ‘max_width’

Just remove old arguments (max_width, max_height, use_thumbnail_aspect_ratio, background_color) from last South migrations file.

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.1.tar.gz (2.8 kB view details)

Uploaded Source

File details

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

File metadata

File hashes

Hashes for django-resized-0.3.1.tar.gz
Algorithm Hash digest
SHA256 4b317d75f0d9cf0e21d63823482d55a2ae8b8849afaa0fa2d11be18bc94466fd
MD5 6b0af2fbbd5bd64e3f564956e19b6442
BLAKE2b-256 5488db0f1b83ce66b9178ac57c7eeed73c038710fa41ec1cf162ea78fce1b703

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