-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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: add a background
option/prop to replace the alpha layer
#4642
Conversation
This optional color specifies which background to use when removing the alpha channel if the output format doesn't support transparency.
…ranch 'main' of git.luolix.top-beeb:withastro/astro into image-background-prop
🦋 Changeset detectedLatest commit: aba574b 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 |
Amazing, cc-ing @tony-sull |
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.
Very nice!
I've been hesitant to add image transforms that aren't supported by Squoosh (we're in the process of making the sharp
dependency optional), but I think the API here is generic enough that the Squoosh loader can just log a console warning that background
isn't supported 🎉
Excellent test and docs coverage here, @beeb! I'll leave this open for now pending a review from @withastro/maintainers-docs |
Thank you! Happy to have made my first meaningful OSS contribution :) |
Changes
This PR introduces a new option and prop to the
@astrojs/image
integration.<Image />
and<Picture />
take an optionalbackground
propgetImage()
andgetPicture()
take an optionalbackground
optionrgb()
color codeThis addition fixes #4625
Testing
Tests were added to perform background replacement on transparent images and check that the pixel color matches the requested color. The new parameter was added to existing test fixtures as well.
Docs
README has been updated to reflect the changes.
/cc @withastro/maintainers-docs for feedback!