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},
}
...
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 |
---|
Result with ‘face’ Area defined |
---|
Areas and namedcrop¶
You can also use the built-in “namedcrop” adjustment force a specific crop.
<img src="{% adjust my_model.image "namedcrop" area="face" %}" />