jimp-dev / jimp

An image processing library written entirely in JavaScript for Node, with zero external or native dependencies.
http://jimp-dev.github.io/jimp/
MIT License
13.97k stars 762 forks source link

16 bit tiff does not convert properly #806

Open Pomax opened 4 years ago

Pomax commented 4 years ago

Expected Behavior

one to one conversion from 16 bit tiff to (presumably) 8 bit jpg

Current Behavior

Images that look like this:

image

this is supposed to be an X-Rite color passport, a piece of equipment for color calibration, on a poorly lit but supposedly white background:

image

Failure Information (for bugs)

It seems like the 16 bit tiff data is getting processed as 8 bit data, I don't know if it's throwing away the top byte in each two-byte pair, or whether it's pretending a single 16 bit value is actually two consecutive single byte values, but it's definitely very wrong.

Steps to Reproduce

  1. Generate a 16 bit TIFF image in any random image editor (photoshop, gimp, what have you)
  2. Make Jimp convert it to jpeg (either with write or getBuffer etc)

Context

This might be an example of #664

Pomax commented 4 years ago

Had to do some processing to get my 100+ MB images to work for test cases, but here's a .zip with the tiff file, the .js that converts it to jpg, and the horrendously wrong jpg =)

download

benkoch12 commented 4 years ago

@Pomax did you make any progress on this?

Pomax commented 4 years ago

If you consider switching to sharp progress, then yes. My code now converts from RAW to TIFF using dcraw, and from TIFF to 1200px JPG using sharp.