Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

287
Views
how to store 16 bits buffer to PNG file using sharp.js?

I'm using sharp.js to create PNG images in node.js from a file containing a 16-bit RAW data map.

fs.readFile(myFolder + "frame1250.dat", (err, buf) => {
  let input = Uint16Array.from(buf),
      image = sharp( input, {
                raw: {
                  width: 1544,
                  height: 740,
                  bitdepth: 16,
                  channels : 1
                }
            });
        image.toFile(myFolder+'frame1250.png', (err, info) => { if(!err) console.log(info) });
    })

the info :

{
  format: 'png',
  width: 1544,
  height: 740,
  channels: 3,
  premultiplied: false,
  size: 2438170
}

the output file contains an inconsistent 24-bit color image, instead of a 16-bit grayscale image. any idea ?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!