Skip to content

Commit 7cf15d2

Browse files
Mary HippMary Hipp
authored andcommitted
restore aspect ratio logic
1 parent 9e18ca3 commit 7cf15d2

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

invokeai/frontend/web/src/features/controlLayers/store/canvasSlice.ts

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1340,22 +1340,27 @@ export const canvasSlice = createSlice({
13401340
state.bbox.aspectRatio.value = state.bbox.rect.width / state.bbox.rect.height;
13411341
state.bbox.aspectRatio.isLocked = true;
13421342
} else if (state.bbox.modelBase === 'flux-kontext' && isFluxKontextAspectRatioID(id)) {
1343-
// Flux Kontext has specific output sizes that are not exactly the same as the aspect ratio. Need special handling.
1344-
if (id === '1:1') {
1345-
state.bbox.rect.width = 1024;
1346-
state.bbox.rect.height = 1024;
1343+
if (id === '3:4') {
1344+
state.bbox.rect.width = 880;
1345+
state.bbox.rect.height = 1184;
13471346
} else if (id === '4:3') {
1348-
state.bbox.rect.width = 896;
1349-
state.bbox.rect.height = 1280;
1350-
} else if (id === '3:4') {
1351-
state.bbox.rect.width = 1280;
1352-
state.bbox.rect.height = 896;
1347+
state.bbox.rect.width = 1184;
1348+
state.bbox.rect.height = 880;
1349+
} else if (id === '9:16') {
1350+
state.bbox.rect.width = 752;
1351+
state.bbox.rect.height = 1392;
1352+
} else if (id === '16:9') {
1353+
state.bbox.rect.width = 1392;
1354+
state.bbox.rect.height = 752;
13531355
} else if (id === '21:9') {
1354-
state.bbox.rect.width = 1408;
1355-
state.bbox.rect.height = 768;
1356+
state.bbox.rect.width = 1568;
1357+
state.bbox.rect.height = 672;
13561358
} else if (id === '9:21') {
1357-
state.bbox.rect.width = 768;
1358-
state.bbox.rect.height = 1408;
1359+
state.bbox.rect.width = 672;
1360+
state.bbox.rect.height = 1568;
1361+
} else if (id === '1:1') {
1362+
state.bbox.rect.width = 880;
1363+
state.bbox.rect.height = 880;
13591364
}
13601365
state.bbox.aspectRatio.value = state.bbox.rect.width / state.bbox.rect.height;
13611366
state.bbox.aspectRatio.isLocked = true;

invokeai/frontend/web/src/features/controlLayers/store/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ export type StagingAreaImage = {
421421
offsetY: number;
422422
};
423423

424-
export const zAspectRatioID = z.enum(['Free', '16:9', '3:2', '4:3', '1:1', '3:4', '2:3', '9:16']);
424+
export const zAspectRatioID = z.enum(['Free', '21:9', '9:21', '16:9', '3:2', '4:3', '1:1', '3:4', '2:3', '9:16']);
425425

426426
export const zImagen3AspectRatioID = z.enum(['16:9', '4:3', '1:1', '3:4', '9:16']);
427427
export const isImagenAspectRatioID = (v: unknown): v is z.infer<typeof zImagen3AspectRatioID> =>
@@ -431,7 +431,7 @@ export const zChatGPT4oAspectRatioID = z.enum(['3:2', '1:1', '2:3']);
431431
export const isChatGPT4oAspectRatioID = (v: unknown): v is z.infer<typeof zChatGPT4oAspectRatioID> =>
432432
zChatGPT4oAspectRatioID.safeParse(v).success;
433433

434-
export const zFluxKontextAspectRatioID = z.enum(['21:9', '4:3', '1:1', '3:4', '9:21']);
434+
export const zFluxKontextAspectRatioID = z.enum(['21:9', '4:3', '1:1', '3:4', '9:21', '16:9', '9:16']);
435435
export const isFluxKontextAspectRatioID = (v: unknown): v is z.infer<typeof zFluxKontextAspectRatioID> =>
436436
zFluxKontextAspectRatioID.safeParse(v).success;
437437

0 commit comments

Comments
 (0)