Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow joining a batch of images with a single mask #3412

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dennwc
Copy link

@dennwc dennwc commented May 6, 2024

Previously, JoinImageWithAlpha required a batch of images to match a batch of masks. But for some use cases it's easier to provide a batch of images and a single mask.

This change automatically repeats the mask for all images in a batch.

In the same spirit, PorterDuffImageComposite will now allow a single mask for a batch of images (for both src and dst).

But also, PorterDuffImageComposite will apply the same logic to src and dst: if src contains one image, and dst is a batch it will repeat src to match dst (or the opposite).

Previously, JoinImageWithAlpha required a batch of images to match a batch of masks. But for some use cases it's easier to provide a batch of images and a single mask.

This change automatically repeats the mask for all images in a batch.

In the same spirit, PorterDuffImageComposite will now allow a single mask for a batch of images (for both src and dst).

But also, PorterDuffImageComposite will apply the same logic to src and dst: if src contains one image, and dst is a batch it will repeat src to match dst (or the opposite).
@shawnington
Copy link
Contributor

for most use cases it seems like only providing one mask to a batch would be an accident, perhaps a toggle to enable single mask usage without changing the default behavior would make this better.

the default mode of failure when not provided multiple masks seems ideal for most users. Realizing you unintentionally only provided one mask after processing a large batch could be... well... frustrating

@dennwc
Copy link
Author

dennwc commented May 7, 2024

@shawnington currently you will still get no error if you only provide one mask. It won't fail, it will just pick the first image from the batch and will mask it, ignoring everything else. So in scenario you described, you will still notice it a bit too late, I'm afraid.

I don't feel strongly about this change, it could be achieved with RepeatMaskBatch, for example. This change just allows a bit cleaner workflows when you generate a lot of base images for the same mask (upscale with a mask, inpaint, etc).

@shawnington
Copy link
Contributor

@shawnington currently you will still get no error if you only provide one mask. It won't fail, it will just pick the first image from the batch and will mask it, ignoring everything else. So in scenario you described, you will still notice it a bit too late, I'm afraid.

I don't feel strongly about this change, it could be achieved with RepeatMaskBatch, for example. This change just allows a bit cleaner workflows when you generate a lot of base images for the same mask (upscale with a mask, inpaint, etc).

Gotcha, Id still go with a toggle to preserve original behavior and let people know what enabling it will do. Seems like a straightforward quality of life upgrade to existing behavior though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants