Reproduce partially transparent affine backgrounds exactly#212
Merged
kipcole9 merged 1 commit intoJul 9, 2026
Merged
Conversation
Collaborator
|
I knew that I was handling pre-multiplied badly - you fixing this area is really fabulous, thank you. |
Contributor
Author
Ah, I think the pre-existing premultiply/unpremultiply in resize is fine. This one was actually my doing. A quirk in when libvips inserts the background fill (after premultiply, before unpremultiply) which ended up warping the color bands if the background had alpha. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A partially transparent
:backgroundinaffine/3,rotate/3,translate/4andshear/4came back distorted because libvips injects it raw into a premultiplied space, so the output unpremultiply scaled the color bands bymax_alpha / alpha:Now the image and background are premultiplied first and the affine runs with
premultiplied: true.Note: Since
vips_rotate()doesn't expose thepremultipliedoption,rotate/3sends alpha images throughaffine/3instead.vips_rotate()is a wrapper overvips_affine()under the hood, so this is lossless.