GithubHelp home page GithubHelp logo

juiopy / django-resized Goto Github PK

View Code? Open in Web Editor NEW

This project forked from un1t/django-resized

0.0 0.0 0.0 210 KB

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

Python 100.00%

django-resized's Introduction

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.11, 2.0, 2.1, 2.2, 3.0, 3.1, 3.2
  • 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 0..100, -1 means default
  • 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

django-resized's People

Contributors

un1t avatar gagaro avatar predatell avatar ad-eric avatar vycius avatar thanosd avatar syndbg avatar bashu avatar juiopy avatar leonardoarroyo avatar mikaraunio avatar pdewacht avatar scottmcginness avatar serhiyromanov avatar lampslave avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.