Skip to content

Latest commit

 

History

History
67 lines (45 loc) · 1.46 KB

adjustments.rst

File metadata and controls

67 lines (45 loc) · 1.46 KB

Adjustments

Daguerre provides a variety of adjustments to use when processing images, as well as an API for registering custom adjustments.

Adjustment

Built-In Adjustments

Fit

Fill

Crop

RatioCrop

NamedCrop

When used with the template tag, these adjustments should be referred to by their lowercase name:

{% adjust image "fit" width=300 %}

See /guides/template-tags for examples.

Custom Adjustments

You can easily add custom adjustments for your particular project. For example, an adjustment to make an image grayscale might look something like this:

# Somewhere that will be imported.
from daguerre.adjustments import Adjustment, registry
from PIL import ImageOps

@registry.register
class GrayScale(Adjustment):
    def adjust(self, image, areas=None):
        return ImageOps.grayscale(image)
    adjust.uses_areas = False

Now you can use your adjustment in templates:

{% adjust image "grayscale" %}