jimp-dev / jimp

An image processing library written entirely in JavaScript for Node, with zero external or native dependencies.
MIT License
13.64k stars 759 forks source link

getPixelColor returns no hex #1116

Open mimeie opened 1 year ago

mimeie commented 1 year ago

Expected Behavior

return the hex value of a green pixel. in this example from: https://upload.wikimedia.org/wikipedia/commons/d/de/Color-Green.JPG

following code is used:

Jimp.read('https://upload.wikimedia.org/wikipedia/commons/d/de/Color-Green.JPG', (err, green) => {
   if (err) throw err;
   var color = green.getPixelColor(20, 20);   
   console.log('getpixelcolor ?: ' + color); 
   console.log(Jimp.intToRGBA(color)); 
   console.log('getpixelcolor hex:' + color.toString(16));
});

Current Behavior

I get a Pixel Color in decimal as a return value. which is some kind of magenta. The RGB Conversion seems fine, just the "a" value cannot be correct as far as I know

this is the log:

21:50:23.023 | info | javascript.0 (4257) script.js.common.Garagentor: getpixelcolor ?: 16712191
21:50:23.024 | info | javascript.0 (4257) script.js.common.Garagentor: {'r':0,'g':255,'b':1,'a':255}
21:50:23.025 | info | javascript.0 (4257) script.js.common.Garagentor: getpixelcolor hex:ff01ff

Failure Information (for bugs)

Steps to Reproduce

described above

Screenshots

Context

Failure Logs

i don't have anything more

hipstersmoothie commented 1 year ago

If anyone wants to submit a PR to fix I'm able to review and merge!

SelfDevTV commented 2 weeks ago

EDIT: I know the solution and will send a PR @hipstersmoothie

I needed that library for exact that reason :D i have the same bug. The images look like that:

Top left small image is the original, the big one is the same but crafted via getPixelColor:

image