Skip to content
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

Merged
merged 25 commits into from
Sep 7, 2022

Conversation

beeb
Copy link
Contributor

@beeb beeb commented Sep 6, 2022

Changes

This PR introduces a new option and prop to the @astrojs/image integration.

  • <Image /> and <Picture /> take an optional background prop
  • getImage() and getPicture() take an optional background option
  • This new parameter accepts strings:

This 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!

@beeb beeb requested a review from a team as a code owner September 6, 2022 15:23
@changeset-bot
Copy link

changeset-bot bot commented Sep 6, 2022

🦋 Changeset detected

Latest commit: aba574b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@astrojs/image Minor

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

@github-actions github-actions bot added the pkg: integration Related to any renderer integration (scope) label Sep 6, 2022
@matthewp
Copy link
Contributor

matthewp commented Sep 6, 2022

Amazing, cc-ing @tony-sull

Copy link
Contributor

@tony-sull tony-sull left a 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 🎉

@tony-sull
Copy link
Contributor

Excellent test and docs coverage here, @beeb! I'll leave this open for now pending a review from @withastro/maintainers-docs

@beeb
Copy link
Contributor Author

beeb commented Sep 6, 2022

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 :)

@tony-sull tony-sull self-assigned this Sep 7, 2022
@tony-sull tony-sull merged commit e4348a4 into withastro:main Sep 7, 2022
@astrobot-houston astrobot-houston mentioned this pull request Sep 7, 2022
@beeb beeb deleted the image-background-prop branch September 7, 2022 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: integration Related to any renderer integration (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

@astrojs/image fails to convert black and transparent png to visible jpg image
3 participants