-
-
Notifications
You must be signed in to change notification settings - Fork 54
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
Handle images with an alpha channel #105
Comments
I love this. I don’t think there is necessarily a one-case fits all default here but I think it’s worth starting as an opt-in option, |
I'm not SVG expert, but I just ran a couple of tests with Sharp against a few SVGs, including just a solid rectangle I made, and all said they had alpha, even if nothing was showing. Not surprised, but may make this a little harder to pin down exactly. As a user option though if you did |
Was thinking sorting out use cases might be the easiest way to proceed here. Thinking out loud here so others can chime in. Use CasesIn both cases, the user has requested An image with unknown transparencyFor whatever reason, I have an image I didn't create and therefore don't realise it has transparent sections (OSes and browsers aren't always good and highlighting this unless you're in image editing software) In this case I would like Eleventy-img to notify me of the potential issue Solution options
An image with known transparencyIn the case I am aware I have a transparent image, I want to tell Eleventy-img to only output alpha supporting formats. Solution options
Perhaps a blend of these - log the issue only if Part of me really wants to error & fail because jpegs will look broken, but part of me wants to let the dev make that final decision and just try to nudge them along. Btw, I'll be happy to PR this if it's useful enough 👍🏼 |
Putting this one in the enhancement queue but I’m still a fan of it. I think we’ll need to have a very clear about the behavior up front though. Specifically, let’s document what happens when an input image has transparency, perhaps under a
If an image doesn’t have transparency, current behavior is maintained (and the value of |
|
Duplicate of #71 |
Changed my mind a bit here, I like having the transparency part of #71 as a separate issue. Reopening |
Shipping with v6.0.0-beta.1.
Ruleset is:
When filtering changes formats, debug messages are logged. |
A little on the fence about not including webp in the minimum viable list but playing it safe there for now |
This also adds a |
I think it might be useful if eleventy-img helped with transparent images. A PNG can be used as a source and will output alpha channels on AVIF and WebP, but if you've requested a JPEG output then you get a little bit screwed.
What I've done in my configuration currently is checked the extension and swapped my output format to match the input, but that doesn't seem great. I think I'll change that out and
require
the sharp package and do asharp.hasAlpha()
, but it seems like this could be a useful thing to have built in to eleventy-img.I'm not exactly sure what the best behaviour should be, but that's the point of opening this ticket for discussion.
Perhaps it should throw an error if the input uses alpha and a source like jpeg doesn't support it? Or warn and ignore the jpeg format?
Thoughts around this? Is it outside of the scope and goals of the plugin? Better ways to do it? I'd be curious what other use cases people have come up against with alpha channel images and what they did to solve them.
The text was updated successfully, but these errors were encountered: