Skip to content

Commit

Permalink
fix(api): convert blend sources to the same size as the mask
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube committed Feb 14, 2023
1 parent 3544e23 commit d1b2506
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions api/onnx_web/chain/blend_mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@ def blend_mask(
) -> Image.Image:
logger.info("blending image using mask")

l_mask = Image.new("RGBA", mask.size, color="black")
l_mask.alpha_composite(mask)
l_mask = l_mask.convert("L")
mult_mask = Image.new("RGBA", mask.size, color="black")
mult_mask.alpha_composite(mask)
mult_mask = mult_mask.convert("L")

if is_debug():
save_image(server, "last-mask.png", mask)
save_image(server, "last-mask-l.png", l_mask)
save_image(server, "last-mult-mask.png", mult_mask)

return Image.composite(sources[0], sources[1], l_mask)
for source in sources:
source.thumbnail(mult_mask.size)

return Image.composite(sources[0], sources[1], mult_mask)

0 comments on commit d1b2506

Please sign in to comment.