-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
[@astrojs/image] flatten background only if alpha channel isn't supported #4800
[@astrojs/image] flatten background only if alpha channel isn't supported #4800
Conversation
🦋 Changeset detectedLatest commit: 203aa8c The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Looks good to me, I'll make sure the docs mark this as a sharp
-only feature once the WASM work is merged in
Hey there! I initially added the option to replace the background with a solid color in The initial behavior (allowing replacing alpha with color for all formats) is useful because such images have a smaller filesize. This is why I added this feature and how I'm using it in my projects (I have a source of truth as transparent PNG and generate an optimized image in If that's OK, I will soon make a PR that restores the initial behavior, assuming that when the user passes a |
Pinging @tony-sull to see if that would be ok. (here is a preview of the changes beeb@7a78ce6 ) |
@beeb changing the current behavior would be a breaking change, I'd definitely recommend starting up an RFC discussion before you dive too far into a PR to get some feedback on the idea 🙌 Erika opened a discussion not long ago to kickstart a cleanup of Personally I've always been torn on exposing so many sharp-specific props through our components - a general "make |
Cheers @tony-sull , I'll pitch in on the discussion thread. Note that this PR #4800 was a breaking change to the behavior I implemented. But it was never documented as such. |
Changes
Following up #4642, these changes make sure we keep transparency unless the output format doesn't support alpha channel.
I also took the liberty to allow
rgba
inColorDefinition
, makes it possible to use transparency when combined with #4438 without TS errors.Testing
The existing tests assume the background is flattened every time. I went ahead and specified
jpeg
as output format for existing fixtures.Docs
/cc @withastro/maintainers-docs