Skip to content

Latest commit

 

History

History
66 lines (46 loc) · 2.1 KB

areas.rst

File metadata and controls

66 lines (46 loc) · 2.1 KB

Smart Cropping with Areas

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

Use the AreaWidget

Daguerre provides a widget which can be used with any ImageField to edit Areas <.Area> 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},
    }
    ...

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

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

Adjustments with Areas

After you define Areas <.Area> 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
image
Result with 'face' Area defined
image

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" %}" />

image