From b631de4cb57bed7fd050cce33b77a062d353bf36 Mon Sep 17 00:00:00 2001 From: Kent Keirsey <31807370+hipsterusername@users.noreply.github.com> Date: Mon, 7 Jul 2025 20:30:33 -0400 Subject: [PATCH] consistency --- .../web/src/features/imageActions/actions.ts | 26 +++++-------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/invokeai/frontend/web/src/features/imageActions/actions.ts b/invokeai/frontend/web/src/features/imageActions/actions.ts index 31d88d444e..885b1105c6 100644 --- a/invokeai/frontend/web/src/features/imageActions/actions.ts +++ b/invokeai/frontend/web/src/features/imageActions/actions.ts @@ -87,32 +87,20 @@ export const createNewCanvasEntityFromImage = async (arg: { const state = getState(); const { x, y } = selectBboxRect(state); + const base = selectBboxModelBase(state); + const ratio = imageDTO.width / imageDTO.height; + const optimalDimension = getOptimalDimension(base); + const { width, height } = calculateNewSize(ratio, optimalDimension ** 2, base); + let imageObject: CanvasImageState; - let resizeWidth: number; - let resizeHeight: number; - if (withResize) { - // Use the same resizing logic as newCanvasFromImage - const base = selectBboxModelBase(state); - const ratio = imageDTO.width / imageDTO.height; - const optimalDimension = getOptimalDimension(base); - const { width, height } = calculateNewSize(ratio, optimalDimension ** 2, base); - resizeWidth = width; - resizeHeight = height; - } else { - // Use current bbox dimensions - const { width, height } = selectBboxRect(state); - resizeWidth = width; - resizeHeight = height; - } - - if (withResize && (resizeWidth !== imageDTO.width || resizeHeight !== imageDTO.height)) { + if (withResize && (width !== imageDTO.width || height !== imageDTO.height)) { const resizedImageDTO = await uploadImage({ file: await imageDTOToFile(imageDTO), image_category: 'general', is_intermediate: true, silent: true, - resize_to: { width: resizeWidth, height: resizeHeight }, + resize_to: { width, height }, }); imageObject = imageDTOToImageObject(resizedImageDTO); } else {