Skip to content

Commit b631de4

Browse files
hipsterusernamepsychedelicious
authored andcommitted
consistency
1 parent 099ebdb commit b631de4

File tree

1 file changed

+7
-19
lines changed
  • invokeai/frontend/web/src/features/imageActions

1 file changed

+7
-19
lines changed

invokeai/frontend/web/src/features/imageActions/actions.ts

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -87,32 +87,20 @@ export const createNewCanvasEntityFromImage = async (arg: {
8787
const state = getState();
8888
const { x, y } = selectBboxRect(state);
8989

90-
let imageObject: CanvasImageState;
91-
let resizeWidth: number;
92-
let resizeHeight: number;
90+
const base = selectBboxModelBase(state);
91+
const ratio = imageDTO.width / imageDTO.height;
92+
const optimalDimension = getOptimalDimension(base);
93+
const { width, height } = calculateNewSize(ratio, optimalDimension ** 2, base);
9394

94-
if (withResize) {
95-
// Use the same resizing logic as newCanvasFromImage
96-
const base = selectBboxModelBase(state);
97-
const ratio = imageDTO.width / imageDTO.height;
98-
const optimalDimension = getOptimalDimension(base);
99-
const { width, height } = calculateNewSize(ratio, optimalDimension ** 2, base);
100-
resizeWidth = width;
101-
resizeHeight = height;
102-
} else {
103-
// Use current bbox dimensions
104-
const { width, height } = selectBboxRect(state);
105-
resizeWidth = width;
106-
resizeHeight = height;
107-
}
95+
let imageObject: CanvasImageState;
10896

109-
if (withResize && (resizeWidth !== imageDTO.width || resizeHeight !== imageDTO.height)) {
97+
if (withResize && (width !== imageDTO.width || height !== imageDTO.height)) {
11098
const resizedImageDTO = await uploadImage({
11199
file: await imageDTOToFile(imageDTO),
112100
image_category: 'general',
113101
is_intermediate: true,
114102
silent: true,
115-
resize_to: { width: resizeWidth, height: resizeHeight },
103+
resize_to: { width, height },
116104
});
117105
imageObject = imageDTOToImageObject(resizedImageDTO);
118106
} else {

0 commit comments

Comments
 (0)