jimp-dev/jimp

Question about reading 24-bit bmp files

Open

#1 026 ouverte le 7 juil. 2021

Voir sur GitHub
 (1 commentaire) (0 réactions) (0 assignés)JavaScript (785 forks)batch import
bughelp wantedreproduction needed

Métriques du dépôt

Stars
 (13 218 stars)
Métriques de merge PR
 (Aucune PR mergée en 30 j)

Description

I have a 24-bit bmp file that I want to get the rgb values for the pixels. I'm trying to use Jimp. If I open the image in GIMP and examine pixel 0,0 the rgb values are r: 45, g: 203, b: 203. However, if I use Jimp and the following code:

Jimp.read(fileToRead)
          .then(image => {
            console.log(Jimp.intToRGBA(image.getPixelColor(0,0)))
          })
          .catch(err => {
            console.log(err);
          })

I get { r: 173, g: 200, b: 150, a: 255 }

By eye, r: 45, g: 203, b: 203 is the correct color. So what am I doing wrong? Do I need to use some option to tell Jimp it's 24-bit? Can Jimp read 24-bit? Internally it's using node mod bmp-js which supposedly can decode 24 bit. Am I missing some basic knowledge about bmp format?

Thanks.

Guide contributeur