sharp
sharp copied to clipboard
How to combine individual R,G,B channels into 16bit output?
What are you trying to achieve?
Selectively extracting single R,G and B channels from three different 16bit input tiff files. Then combining them to a new 16bit output tiff. With srgb output color space (8bit) everything works as expected. As I switch to rgb16 colourspace for output I get a pure black image.
Have you searched for similar questions?
Yes but nothing yet seems to point me on what I'm doing wrong.
Are you able to provide a minimal, standalone code sample that demonstrates this question?
Promise.all([
sharp('input1.tif')
.extractChannel('red')
.toColourspace('b-w')
.toBuffer(),
sharp('input2.tif')
.extractChannel('green')
.toColourspace('b-w')
.toBuffer(),
sharp('input3.tif')
.extractChannel('blue')
.toColourspace('b-w')
.toBuffer()
])
.then(images => {
sharp(images[0])
.joinChannel([
images[1],
images[2]
])
//.toColorspace('srgb')
.toColorspace('rgb16')
.tiff({
compression: 'none'
})
.toFile('output.tif');
});
Output file:
Are you able to provide a sample image that helps explain the question?
Too large of files.
Hi, does replacing .toColourspace('b-w')
with .toColourspace('grey16')
work?
Hi, no. Behaviour doesn't change. Still pitch black output.
Were you able to make any progress with this? If not, are you able to provide sample input image(s) that allow someone else to reproduce.