Django Transparent Image Neat Transformer
Usage
You must define your transformation in your TINT_TRANSFORMATIONS settings
variable.
You set your images on your models puting a ForeignKey to
tint.models.Image.
Then you put your images in your templates using the at_transformation filter. Example:
{% load tint %}
<img src="{{ mymodel.my_image_field|at_transformation:"my-transformation-definition" }}" />
If you use django-jinja you only have to use the image_at_transformation function. Example:
<img src="{{ image_at_transformation(mymodel.my_image_field, "my-transformation-definition") }}" />
Default ImageProc Actions
Django-tint default Image Processor comes with some actions, here you have the list:
Action |
Description |
Params |
|---|---|---|
crop |
Crop an image to a width and height. |
height, width, align, valign |
scale |
Scale an image to a width and height (deforming it). |
height, width |
fit |
Scale an image to a width and height and crop the overflow. |
height, width, align, valign |
watermark |
Paste a watermark on a image. |
watermark_image, opacity |
grayscale |
Convert the image to grayscale. |
|
flip |
Flip the image vertically. |
|
mirror |
Flip the image horizontally. |
|
equalize |
Equalize the image histogram. |
|
autocontrast |
Maximize (normalize) image contrast. |
cutoff |
invert |
Invert the image colors. |
|
convert |
Convert image mode (L, RGB or CYMK). |
mode |
Configuration
In Django-tint you can define your ImageProc class (normally will be a subclass
of the DefaultImageProc) to add your own image transformations. You can use it
configuring the TINT_IMAGE_PROCESSOR settings variable. Example:
TINT_IMAGE_PROCESSOR = 'myapp.my_image_processor_module.MyImageProcessorClass'
If the variable is not defined the DefaultImageProc is used.
Then you can configure your transformations as a dictionary. The name of the transformation is the key, and the value is a list of “actions”. An action is a dictionary with one key ‘action’ with the name of the action, and the other keys the parameters to use in this action. Example:
TINT_TRANSFORMATIONS = {
'example1': [
{
"action": 'fit',
"width": 1024,
"height": 768,
"align": 'center',
"valign": 'middle',
},
{
"action": 'watermark',
"image": 'example.watermark.png',
"opacity": 0.5,
},
],
'example2': [
{
"action": 'fit',
"width": 800,
"height": 600,
"align": 'center',
"valign": 'middle',
},
{
"action": 'watermark',
"image": 'example.watermark.png',
"opacity": 0.5,
},
]
}
You can define the the removing of deleted images or thumnails model instances, remove the image file with the settings TINT_KEEP_THUMBNAILS and TINT_KEEP_IMAGES, the default value is True to both settings.
You can define your file output format and your file output extension with the settings TINT_IMAGE_OUTPUT_FORMAT and TINT_IMAGE_OUTPUT_EXTENSION. The default value is None this means use the same format and extension of the origin file. Example:
TINT_IMAGE_OUTPUT_FORMAT = "png" TINT_IMAGE_OUTPUT_EXTENSION = ".png"
Metadata
Release files for django-tint 0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-tint-0.1.tar.gz | 9.0 kB | Without provenance | Details for django-tint-0.1.tar.gz |
Release files / django-tint-0.1.tar.gz
| Download URL | django-tint-0.1.tar.gz |
|---|---|
| Size | 9.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9372d437e2ab0e74acf6041530969da68fabfdfbe9ec09597e0c691fae576519
|
|
BLAKE2b-256 checksum How to use checksums |
6361b59bd04c88ce92cb8a0a42f2141ba3dac86bc9d196c5972662d4f09d4f82
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for django-tint 0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.