Image compressor for Django apps.
Project description
Django Image Compressor
Django Image Compressor is a tool to compress your images. Easy to plug-in and easy to use.
Installation
To install django-image-compressor
$ pip install django-image-compressor
Add the app to your project:
# settings.py
INSTALLED_APPS = (
...
'django-image-compressor',
...
)
Usage
Package will add additional 4 fields to your forms. You can compress your images by reducing the quality of the images or resize them or both. If you leave input width and/or height fields empty and try to resize your image, sizes will be reduced twice. Only compressed images will be saved to your db and original ones will be ignored.
In order to use the compressor, first create a ModelForm in forms.py and add ImageCompressorFormMixin to your form:
# forms.py
from django import forms
from django-image-compressor.mixins import ImageCompressorFormMixin
class YourImageUploadForm(ImageCompressorFormMixin, forms.ModelForm):
...
compressed_image_fields = ('your_image_field_1', 'your_image_field2', ...)
...
If you want to add compressor to your Django Admin Site, then add ImageCompressorAdminMixin and the created form to your ModelAdmin class.
# admin.py
from django.contrib import admin
from django-image-compressor.mixins import ImageCompressorAdminMixin
class YourModelAdmin(ImageCompressorAdminMixin, admin.ModelAdmin):
...
custom_form = SliderCreateForm
...
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
Hashes for django-image-compressor-0.3.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5434a81c75068b4d6904a8d3e27930e6b1b88056e818079258e3f2fe59ec1e07 |
|
MD5 | 2dc9ab3375cf689c640547cce980adee |
|
BLAKE2b-256 | 180198be3f6db97e2ca733c1a36e9bfb10b12516c77f53ad45e8bfbe59f7e707 |