.rgba(false) does not work
See original GitHub issueExpected Behavior
Expect to save the image without the alpha channel.
Current Behavior
Getting an image byte-wise re-interpretted from RGBA to RGB.
Failure Information (for bugs)
Steps to Reproduce
require('jimp').read('test.png', function (err, image) {
image.rgba(false).write('out.png');
})
Screenshots In (and expected out): Actual out:
Context
- Jimp Version: 0.6.0
- Operating System: Windows 10
- Node version: 8.11.3
Failure Logs
Issue Analytics
- State:
- Created 5 years ago
- Reactions:8
- Comments:5
Top Results From Across the Web
Receive incorrect alpha channel when convert rgba color to hex
Using a bitwise | (or) operator on a floating-point value does not make sense. You'll have to use ~~(achannel * 255) to get...
Read more >color rgba doesn´t work anymore on new computer - CSS-Tricks
Recently got new computer(Windows 8, Firefox 37.0 and newest version of Opera and Chrome)and the background-color using rgba values doesn't show ...
Read more >rgba() - CSS: Cascading Style Sheets - MDN Web Docs - Mozilla
The rgba() functional notation expresses a color according to its red, green, and blue components. An optional alpha component represents ...
Read more >Untitled
markdownlint-disable no-inline-html --> <details open> <summary><b>RGBA</b> Color Space</summary> ```ts // note that the import name can be anything ...
Read more >HTML RGB and RGBA Colors - W3Schools
In HTML, a color can be specified as an RGB value, using this formula: ... is a number between 0.0 (fully transparent) and...
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 FreeTop 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
Top GitHub Comments
If you’re saving PNGs, then you can try the
colorType()
method on the image:I’m not Jimp contributor, it’s just a thing that I’ve found out in the docs.
I think I have found the problem.
It appears that the encoder for PNG files are setting both output AND input alpha channel to
image.rgba()
. This results in the input being read as RGB instead of RGBA which destroys the output.The solution should be to change Jimp/packages/type-png/src/index.js:50 from
inputHasAlpha: data._rgba
toinputHasAlpha: data.bitmap.alpha
I tried to fork it and make the change but one of the tests fail, and I am unable to figure out what the test even does. The important part for me is that the image ends up looking as I expect it to.