@astrojs/image: add a background option/prop to replace the alpha layer#4642
@astrojs/image: add a background option/prop to replace the alpha layer#4642tony-sull merged 25 commits intowithastro:mainfrom
background option/prop to replace the alpha layer#4642Conversation
This optional color specifies which background to use when removing the alpha channel if the output format doesn't support transparency.
…ranch 'main' of github.com-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 |
tony-sull
left a comment
There was a problem hiding this comment.
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/imageintegration.<Image />and<Picture />take an optionalbackgroundpropgetImage()andgetPicture()take an optionalbackgroundoptionrgb()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!