Smart Cropping with Areas

Daguerre allows you to influence how images are cropped with Areas.

Use the AreaWidget

Daguerre provides a widget which can be used with any ImageField to edit Areas for that image file. Add this formfield override to your ModelAdmin to enable the widget.

from daguerre.widgets import AreaWidget

class YourModelAdmin(admin.ModelAdmin):
    formfield_overrides = {
        models.ImageField: {'widget': AreaWidget},
    }
    ...
Screenshot of the Area Widget in the admin.

The AreaWidget allows you to define areas of an image with click-and-drag. (Screenshot includes Grappelli.)

Adjustments with Areas

After you define Areas for an image in the admin, adjustments that remove parts of the image (such as crop) will protect those parts of the image during processing. See the difference in this adjustment.

<img src="{% adjust my_model.image "fill" width=600 height=200 %}" />
Result without ‘face’ Area defined
../_images/cat_face_not_protected.jpg
Result with ‘face’ Area defined
../_images/cat_face_protected.jpg

Areas and namedcrop

You can also use the built-in “namedcrop” adjustment force a specific crop.

<img src="{% adjust my_model.image "namedcrop" name="face" %}" />
../_images/cat_named_crop.jpg