File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
invokeai/frontend/web/src/features/controlLayers/store Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -616,20 +616,32 @@ export const controlLayersSlice = createSlice({
616
616
iiLayerAdded : {
617
617
reducer : ( state , action : PayloadAction < { layerId : string ; imageDTO : ImageDTO | null } > ) => {
618
618
const { layerId, imageDTO } = action . payload ;
619
+
620
+ // Retain opacity and denoising strength of existing initial image layer if exists
621
+ let opacity = 1 ;
622
+ let denoisingStrength = 0.75 ;
623
+ const iiLayer = state . layers . find ( ( l ) => l . id === layerId ) ;
624
+ if ( iiLayer ) {
625
+ assert ( isInitialImageLayer ( iiLayer ) ) ;
626
+ opacity = iiLayer . opacity ;
627
+ denoisingStrength = iiLayer . denoisingStrength ;
628
+ }
629
+
619
630
// Highlander! There can be only one!
620
631
state . layers = state . layers . filter ( ( l ) => ( isInitialImageLayer ( l ) ? false : true ) ) ;
632
+
621
633
const layer : InitialImageLayer = {
622
634
id : layerId ,
623
635
type : 'initial_image_layer' ,
624
- opacity : 1 ,
636
+ opacity,
625
637
x : 0 ,
626
638
y : 0 ,
627
639
bbox : null ,
628
640
bboxNeedsUpdate : false ,
629
641
isEnabled : true ,
630
642
image : imageDTO ? imageDTOToImageWithDims ( imageDTO ) : null ,
631
643
isSelected : true ,
632
- denoisingStrength : 0.75 ,
644
+ denoisingStrength,
633
645
} ;
634
646
state . layers . push ( layer ) ;
635
647
exclusivelySelectLayer ( state , layer . id ) ;
You can’t perform that action at this time.
0 commit comments