-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Change bits per channel #534
Comments
At the end of the processing pipeline, before generating the output image, 16-bit pixel values are cast to 8-bit - see Lines 675 to 677 in 7ada9db
When you say 32-bits per channel, do you mean an 8-bit per pixel image with 4 channels? If so, you may be looking for quantisation, which is not supported. |
I ran into what I think is a related issue with compatibility with pngjs for
Is there was a way to output a compatible png? |
Hello @jdalton, the following code seems to produce PNG output images from const assert = require('assert');
const pngjs = require('pngjs');
const sharp = require('sharp');
const input = '5_webp_a.webp';
const width = 100;
const height = 100;
let channels = 0;
const pngParser = new pngjs.PNG();
pngParser
.on('parsed', (data) => {
assert.strictEqual(data.length, width * height * channels);
})
.on('error', (err) => {
assert.ifError(err);
});
const transcoder = sharp(input)
.resize(width, height)
.png();
transcoder.on('info', (info) => {
channels = info.channels;
});
transcoder.pipe(pngParser); Perhaps a particularly tricky or complex input image is causing problems? |
Ah yeah. Turns out it was a OptiPNG optimization causing the issue. |
@strarsis has your original question been answered? |
This was meant to be used to solve this issue: peterbraden/node-opencv#436 |
Thanks, this works. And for the other way around |
Is there a feature in sharp for changing bits per channel (e.g. from 32bit or 16bit to 8bit)
before processing/saving the loaded image?
The text was updated successfully, but these errors were encountered: