-
-
Notifications
You must be signed in to change notification settings - Fork 7.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
images: Opacity problem with Resize + Padding with PNG output #12536
Comments
It may be worth noting that the |
This works as expected:
So you must be doing something different. Please provide example. Here's a minimal example that does not reproduce the problem:
|
Many thanks for putting together the minimal example, that's awesome! I spent the last 3 hours trying to work out what's going on. While I still have no idea why this is happening, I submitted a PR which hopefully includes some examples that don't work as expected: jmooring/hugo-testing#10 Results seem to be dependent on what size the image is resized to. Problems also seem to go away when using the WEBP format instead of PNG. |
This works as expected (border is ~ 50% opaque blue):
This does not work as expected (border is some other transparent color):
But this (convert to webp using second construct) works fine:
So, for now, use the first construct. Example:
|
images.Padding
does not support transparency when using PNG format
What version of Hugo are you using (
hugo version
)?Does this issue reproduce with the latest release?
Yes.
Report
The
images.Padding
function currently ignores the transparency setting when padding a PNG image. While the documentation does state 'conversion to WEBP is required to support transparency' (under Other recipes), I can't see a reason why PNG shouldn't be supported, given that it has an alpha channel. For the moment I have resorted to first converting the image to WEBP, then applying transparent padding, and then converting it back to PNG, but this does not feel like an elegant solution.The text was updated successfully, but these errors were encountered: