Fix Remove Background mask-only and merge-alpha options

Both options inspected pp.image (the original input, normally RGB)
instead of the background-removed RGBA result, so the checkboxes did
nothing. merge_alpha also discarded the convert('RGB') return value.
Operate on the rembg output and keep the converted image.

https: //claude.ai/code/session_014QWKWgKvMevcuvfCnsYoT2
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Claude
2026-06-11 08:13:36 +00:00
committed by QualiaRain
parent 9c0ab938f2
commit 92517f8a58
+6 -7
View File
@@ -98,14 +98,13 @@ class ScriptPostprocessingRembg(scripts_postprocessing.ScriptPostprocessing):
log.error(f'RemoveBackground: model={model} {e}')
return pp
if mask_only and pp.image.mode == "RGBA":
_r, _g, _b, alpha = pp.image.split()
if mask_only and image.mode == "RGBA":
_r, _g, _b, alpha = image.split()
image = alpha
if merge_alpha and pp.image.mode == "RGBA":
flattened = Image.new("RGBA", pp.image.size, "BLACK")
flattened.paste(pp.image, mask=pp.image)
flattened.convert("RGB")
image = flattened
if merge_alpha and image.mode == "RGBA":
flattened = Image.new("RGBA", image.size, "BLACK")
flattened.paste(image, mask=image)
image = flattened.convert("RGB")
if isinstance(pp, Image.Image):
pp = scripts_postprocessing.PostprocessedImage(image=image, info={**info, "Rembg": model})