Skip to content

Commit 1bc689d

Browse files
docs(ui): add comments to startingframeimage
1 parent 4829975 commit 1bc689d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

invokeai/frontend/web/src/features/settingsAccordions/components/VideoSettingsAccordion/StartingFrameImage.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,23 @@ export const StartingFrameImage = () => {
4848
if (!originalImageDTO) {
4949
return;
5050
}
51+
52+
// We will create a new editor instance each time the user wants to edit
5153
const editor = new Editor();
54+
55+
// Initialize w/ the existing crop & ratio if there is one
5256
if (startingFrameImage?.crop) {
5357
editor.setCropBox(startingFrameImage.crop.box);
58+
// Due to floating point precision, we need to record the ratio separately - cannot infer from w/hof box
59+
// TODO(psyche): figure out how to not need to save ratio separately, maybe use some "close enough" logic?
5460
editor.setCropAspectRatio(startingFrameImage.crop.ratio);
5561
}
62+
63+
// When the user applies the crop, we will upload the cropped image and store the applied crop box so if the user
64+
// re-opens the editor they see the same crop
5665
editor.onCropApply(async (box) => {
5766
if (objectEquals(box, startingFrameImage?.crop?.box)) {
67+
// If the box hasn't changed, don't do anything
5868
return;
5969
}
6070
const blob = await editor.exportImage('blob');
@@ -76,6 +86,8 @@ export const StartingFrameImage = () => {
7686
)
7787
);
7888
});
89+
90+
// Load the image into the editor and open the modal once it's ready
7991
await editor.loadImage(originalImageDTO.image_url);
8092
openEditImageModal(editor);
8193
}, [dispatch, originalImageDTO, startingFrameImage?.crop, uploadImage]);

0 commit comments

Comments
 (0)