imazen / imazen/imageflow

Wish: Improve anchor parameter

Open
#594 11 comments 0 reactions 0 assignees View on GitHub
! enhancement libimageflow
Dominant language
Rust
Stars
4.4k
Forks
144
PR merge metrics
No merged PRs in 30d

Description

At the moment the url allows for `?anchor=topcenter` to make sure cropping behaves as we need it to when the image is auto-cropped.

But we would like to give our users much more control - but automatically. The idea is that they could mark an area on the image which is important, and the cropper would use this to limit what must stay inside the result, and what can be cropped.

Something like `?anchor=bottomright&focus=22-67,50-90`

The core idea is that the content-editor could select a rectangle on the image determining what's really important - and therefor must stay in the image no matter how we crop it. The example above would have been in %, so the important bits of the above example would be:
1. Within the width from 22% to 67%
2. Within the height of 50% to 90%

Based on this, and also because bottom-right is the anchor, the image would try to crop ensuring that this area will be visible, and expand to top-left from the 67%/90% corner.

Of course it would need to do various corrections if the image doesn't fit.

We believe this would be super-useful for many CMS scenarios, and would also help write the code if you see this is a useful addition.

Note: I noticed this is somehow similar to what the `gravity` in the JSON configuration would do. Maybe it would also be enough to allow a gravity-parameter in the url-syntax?

Contributor guide

Open the contributing guide

Research direction

Start by tracing how the URL’s `anchor` parameter and the JSON `gravity` configuration currently affect auto-cropping; the issue names no source files or tests. Clarify the intended percentage-based `focus` rectangle, correction behavior when it does not fit, and what tests should demonstrate that the selected area remains visible.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
api, computer-graphics
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.