Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add seedCropId optional query param for the /crop endpoint for an image and use the dimensions to set the starting point of the crop #4332

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions kahuna/public/js/crop/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,17 @@ crop.controller('ImageCropCtrl', [
ctrl.maxInputY = () =>
ctrl.originalHeight - ctrl.cropHeight();

const maybeSeedCropId = $stateParams.seedCropId;
const [maybeSeedX1, maybeSeedY1, maybeSeedX2, maybeSeedY2] = maybeSeedCropId?.split("_") || [];

// TODO attempt centering if seed crop dimensions don't fit

ctrl.coords = {
x1: ctrl.inputX,
y1: ctrl.inputY,
x1: maybeSeedX1 || ctrl.inputX,
y1: maybeSeedY1 || ctrl.inputY,
// fill the image with the selection
x2: ctrl.originalWidth,
y2: ctrl.originalHeight
x2: maybeSeedX2 || ctrl.originalWidth,
y2: maybeSeedY2 || ctrl.originalHeight
};

// If we have a square crop, remove any jitter introduced by client lib by using only one side
Expand Down
Loading