Skip to content

Commit c39fa75

Browse files
docs(ui): add comment in useIsTooLargeToUpscale
1 parent f7863e1 commit c39fa75

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

invokeai/frontend/web/src/features/parameters/hooks/useIsTooLargeToUpscale.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,16 @@ const createIsTooLargeToUpscaleSelector = (imageDTO?: ImageDTO) =>
1111
const { maxUpscaleDimension } = config;
1212

1313
if (!maxUpscaleDimension || !upscaleModel || !imageDTO) {
14+
// When these are missing, another warning will be shown
1415
return false;
1516
}
1617

17-
const upscaledPixels = imageDTO.width * scale * imageDTO.height * scale;
18-
return upscaledPixels > maxUpscaleDimension * maxUpscaleDimension;
18+
const { width, height } = imageDTO;
19+
20+
const maxPixels = maxUpscaleDimension ** 2;
21+
const upscaledPixels = width * scale * height * scale;
22+
23+
return upscaledPixels > maxPixels;
1924
});
2025

2126
export const useIsTooLargeToUpscale = (imageDTO?: ImageDTO) => {

0 commit comments

Comments
 (0)