v0.31.1: palette-based RGBA PNG output can add transparent pixels
See original GitHub issuePossible bug
After upgrading to 0.31.1
, compress is changing image color. We are sending a png buffer to sharp to change it’s quality to 95% and it was working fine. But now it’s changing adding these black color
Image attached below
Is this a possible bug in a feature of sharp, unrelated to installation?
yes
- Running
npm install sharp
completes without error. - Running
node -e "require('sharp')"
completes without error.
If you cannot confirm both of these, please open an installation issue instead.
Are you using the latest version of sharp?
- I am using the latest version of
sharp
as reported bynpm view sharp dist-tags.latest
.
If you cannot confirm this, please upgrade to the latest version and try again before opening an issue.
If you are using another package which depends on a version of sharp
that is not the latest, please open an issue against that package instead.
What is the output of running npx envinfo --binaries --system --npmPackages=sharp --npmGlobalPackages=sharp
?
System:
OS: Linux 5.15 Ubuntu 20.04.4 LTS (Focal Fossa)
CPU: (24) x64 12th Gen Intel(R) Core(TM) i9-12900K
Memory: 88.28 GB / 125.61 GB
Container: Yes
Shell: 5.0.17 - /bin/bash
Binaries:
Node: 16.16.0 - ~/.volta/tools/image/node/16.16.0/bin/node
Yarn: 3.2.3 - ~/.volta/tools/image/yarn/1.22.19/bin/yarn
npm: 8.11.0 - ~/.volta/tools/image/node/16.16.0/bin/npm
npmPackages:
sharp: ^0.31.1 => 0.31.1
What are the steps to reproduce?
provide a png to sharp
const finalImage = await sharp(renderedImage).png({ quality: 94 }).toBuffer();
What is the expected behaviour?
It should work like before without adding those black colors
Please provide a minimal, standalone code sample, without other dependencies, that demonstrates this problem
// canvas is @napi-rs/canvas and it's output is working fine. The issue occurs only when passed to shard.
const renderedImage = canvas.png();
const finalImage = await sharp(renderedImage).png({ quality: 94 }).toBuffer();
Please provide sample image(s) that help explain this problem
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Chapter 8: PNG Basics - libpng.org
In the text that follows, I will refer to an RGB image with an alpha channel as an RGBA image. PNG adheres to...
Read more >Transparent PNG Pixel Base64 Encoded
Online PNG pixel generator. Create a transparent PNG Pixels base64 encoded.
Read more >How Do I Convert Palette-Based PNG with Transparency To ...
A way to do this is to first convert the file to jpg -- seems like a problem with the png encoding (or...
Read more >Changelog - High performance Node.js image processing
Resize large images in common formats to smaller, web-friendly JPEG, PNG, WebP, GIF and AVIF images of varying dimensions.
Read more >Export a PNG with transparent background from Blender
By default, Blender doesn't include transparency within a render. ... PNG for File Format and RGBA for Color will export out an image...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
sharp v0.31.2 now available with libvips v8.13.3
Thanks for the fix ❤️