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
[gatsby-plugin-sharp] Fix PNG generation when using the "duotone" option #1506
[gatsby-plugin-sharp] Fix PNG generation when using the "duotone" option #1506
Conversation
Options for PNG and JPEG output need to be set so that "toFormat" in duotone.js actually works. This was working for JPEGs before because we are directly writing those "toFile". PNGs get processed with imagemin before writing them to disk, and require a "correct" (PNG) buffer content.
Deploy preview failed. Built with commit 5f9ae44 https://app.netlify.com/sites/using-styled-components/deploys/5968f5d4cf321c72b7f87157 |
Deploy preview ready! Built with commit dd9e94b |
Deploy preview ready! Built with commit dd9e94b |
Deploy preview ready! Built with commit dd9e94b |
} | ||
// @todo remove once we upgrade to sharp v0.18 which | ||
// adds an alias for "jpg" to toFormat | ||
// @see http://sharp.dimens.io/en/stable/changelog/#v0180-30th-may-2017 |
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.
This seems like the main blocker for upgrading as we "attention" is the default mode for us for cropping https://github.com/jcupitt/libvips/issues/672#issuecomment-307365416
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.
Thanks for the heads up! Didn't have the time to look into the changelog for 0.18 yet, merely stumbled upon that note regarding the alias. "attention" is all I had to mention to the people that I showed plugin-sharp to instantly win them over btw. <3
Everything looks happy 👍 https://596ebdce8ebdd96db650f3e0--image-processing.netlify.com/ |
👍 @KyleAMathews I actually should have added a PNG-and-duotone example to the image-processing example … :-/. Will do! I wish I could get my head around writing tests for this. |
Options for PNG and JPEG output need to be set prior to
raw().toBuffer()
so thattoFormat()
in duotone.js actually works.Things were working for JPEGs before because they are written
toFile()
as JPEGs explicitly. PNGs get processed with imagemin before writing them to disk, which requires a valid (PNG) buffer.When authoring the original feature, I moved the PNG/JPEG output settings after the actual duotone processing (for whatever reason 😬 – I guess I thought they get dropped when doing
raw().toBuffer()
) – this PR reverts that, and cleans up duotone.js.