Repository navigation
Conversation
Collaborator
|
merged via #1502 |
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.
Fixes #819
What's Changing and Why
resize()treats alpha as opacity, so the colour under alpha 0 is lost: the default mode ignores it, and the other blending modes premultiply by alpha (#1459, #1481). That is right for pictures, and wrong when alpha holds something else, like the self-illumination textures in #819.resizenow takesseparateAlpha: true. The colour is resized as if the image were opaque, and the alpha as it is without the option:It works with every
ResizeStrategy. I did it by resizing an opaque copy for the colour and the image itself for the alpha, so neither resizer changes. A flag that skips the premultiply steps would have touched seven code paths across the two resizers. The cost is that it runs the resize twice.The default doesn't change.
What else might be affected
Nothing without the option.
scale,scaleToFit,contain,coverandrotatedon't take it yet; I can add it to them here or in a follow-up if you want it there.Testing
plugin-resizecover every mode at four sizes: the colour equals the resize of an opaque copy, and the alpha equals the resize without the option. 31 of them fail without the change.pnpm build,pnpm lint,pnpm testandpnpm test:browser(Chromium) pass.Tasks
jimp.d.ts(the file no longer exists; the option's type comes from the zod schema)