mirror of
https://github.com/vladmandic/automatic
synced 2026-09-20 01:31:13 +02:00
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:
@@ -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})
|
||||
|
||||
Reference in New Issue
Block a user