mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
fix(ui): add initial image dimensions to state
We need to access the initial image dimensions during the creation of the `ImageToImage` graph to determine if we need to resize the image. Because the `initialImage` is now just an image name, we need to either store (easy) or dynamically retrieve its dimensions during graph creation (a bit less easy). Took the easiest path. May need to revise this in the future.
This commit is contained in:
@ -34,14 +34,14 @@ const InitialImagePreview = () => {
|
||||
isLoading,
|
||||
isError,
|
||||
isSuccess,
|
||||
} = useGetImageDTOQuery(initialImage ?? skipToken);
|
||||
} = useGetImageDTOQuery(initialImage?.imageName ?? skipToken);
|
||||
|
||||
const handleDrop = useCallback(
|
||||
({ image_name }: ImageDTO) => {
|
||||
if (image_name === initialImage) {
|
||||
(droppedImage: ImageDTO) => {
|
||||
if (droppedImage.image_name === initialImage?.imageName) {
|
||||
return;
|
||||
}
|
||||
dispatch(initialImageChanged(image_name));
|
||||
dispatch(initialImageChanged(droppedImage));
|
||||
},
|
||||
[dispatch, initialImage]
|
||||
);
|
||||
|
@ -24,7 +24,7 @@ export interface GenerationState {
|
||||
height: HeightParam;
|
||||
img2imgStrength: StrengthParam;
|
||||
infillMethod: string;
|
||||
initialImage?: string;
|
||||
initialImage?: { imageName: string; width: number; height: number };
|
||||
iterations: number;
|
||||
perlin: number;
|
||||
positivePrompt: PositivePromptParam;
|
||||
@ -211,8 +211,9 @@ export const generationSlice = createSlice({
|
||||
setShouldUseNoiseSettings: (state, action: PayloadAction<boolean>) => {
|
||||
state.shouldUseNoiseSettings = action.payload;
|
||||
},
|
||||
initialImageChanged: (state, action: PayloadAction<string>) => {
|
||||
state.initialImage = action.payload;
|
||||
initialImageChanged: (state, action: PayloadAction<ImageDTO>) => {
|
||||
const { image_name, width, height } = action.payload;
|
||||
state.initialImage = { imageName: image_name, width, height };
|
||||
},
|
||||
modelSelected: (state, action: PayloadAction<string>) => {
|
||||
state.model = action.payload;
|
||||
|
Reference in New Issue
Block a user