Skip to content

Add a SmartCrop control to the new Angular image editor #36315

Description

@oidacra

Description

The new Angular image editor (@dotcms/image-editor, built in #36063 / PR #36236) supports manual crop with aspect presets and orientation, but does not yet expose dotCMS's content-aware SmartCrop filter, which auto-crops an image to a target size by selecting the most relevant region.

Add a SmartCrop control to the editor. Like the rest of the editor, this is a server-side "viewer of the endpoint": the control builds a /contentAsset/image/... filter URL and the server renders it (no client-side pixel work).

Backend contract (already implemented — libvips-only)

The smartcrop filter is registered in com.dotmarketing.image.vips.VipsImageFilterApiImpl (.put("smartcrop", VipsSmartCropImageFilter.class)). It requires DOT_IMAGE_API_USE_LIBVIPS=true (no legacy fallback — same constraint as AVIF and the libvips Rotate filter).

URL form:

/contentAsset/image/{id}/{field}/filter/smartcrop/smartcrop_w/{w}/smartcrop_h/{h}/smartcrop_mode/{mode}

mode is one of attention | entropy | centre. Verified on stage (falconteam-image-editor.dotcms.dev):

  • .../filter/smartcrop/smartcrop_w/500/smartcrop_h/400/smartcrop_mode/attention
  • .../filter/smartcrop/smartcrop_w/500/smartcrop_h/400/smartcrop_mode/entropy
  • .../filter/smartcrop/smartcrop_w/500/smartcrop_h/400/smartcrop_mode/centre
Mode Picks the region by
attention Saliency — visually important areas (default)
entropy Detail / busyness
centre Geometric centre

Surfacing

The exact placement — a mode inside the existing Crop tool vs a separate toolbar control — is deferred to the provided design. The acceptance criteria below are behavior-focused, not layout-specific.

Acceptance Criteria

  • The editor exposes a SmartCrop control that accepts a target width and height in pixels.
  • The control offers all three modes — attention, entropy, centre — defaulting to attention.
  • Selecting SmartCrop with width W, height H, mode M renders a live preview built from …/filter/smartcrop/smartcrop_w/W/smartcrop_h/H/smartcrop_mode/M, like every other edit.
  • Switching the mode with the same W×H re-renders the preview using the new mode.
  • SmartCrop is mutually exclusive with manual Crop and the Resize/output-dimensions: applying SmartCrop clears/overrides them (it already yields the final W×H), mirroring the existing Resize-removes-Crop rule in the URL builder.
  • The applied SmartCrop appears in the edit history (applied-edits list) and can be removed/undone like other edits.
  • Width/height reject non-positive values (min 1); no filter URL is emitted for an incomplete entry (missing W or H).
  • The SmartCrop filter is reflected in the preview address bar / copy-URL like other filters.
  • Unit tests cover the URL-builder branch (each mode → expected params; mutual exclusion with crop/resize) and the control's dispatch.

Priority

Medium

Additional Context

Metadata

Metadata

Assignees

No one assigned

    Type

    No fields configured for Task.

    Projects

    Status
    Future

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions