-
Notifications
You must be signed in to change notification settings - Fork 124
feat(decode): add colorTransform option #39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Without this fix, two unequal buffers did not lead to a test failure.
The cornerstoneWADOImageLoader (https://github.com/cornerstonejs/cornerstoneWADOImageLoader) does its own color transform, so it needs an option to skip to builtin color transform.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the contribution!
lib/decoder.js
Outdated
}; | ||
if (opts) { | ||
if (typeof opts === 'object') { | ||
opts = Object.assign(defaultOpts, opts); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is failing travis since jpeg-js supports much older versions of node that lack Object.assign
I'm not sure how others feel about continuing support for <4, https://nodesource.com/node-by-numbers seems to suggest 0.10 and 0.12 have about ~2% share by # downloads, and supposedly many systems running 0.10/0.12 are not downloading fresh copies.
since we only have 2 options, how do you feel about something explicit?
opts = {
useTArray: typeof opts.useTArray === 'undefined' ? defaultOpts.useTArray : opts.useTArray,
colorTransform: typeof opts.colorTransform === 'undefined' ? defaultOpts.colorTransform : opts.colorTransform,
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! I updated to PR.
Any ideas for how to support 16bit JPEGs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also need support for 16bit JPEGs. The cornerstoneWADOImageLoader has a getData16 function for this purpose (see https://github.com/cornerstonejs/cornerstoneWADOImageLoader/blob/master/codecs/jpeg.js). What would be the best way to bring support for 16bit JPEGs to jpeg-js? Just copy get getData16 function?
Hmm, yeah probably best to just bring in the separate function and keep it a clearly separate flow for now. Let's do that in a different PR though this one looks GTG from my perspective % nit :)
lib/decoder.js
Outdated
defaultOpts.useTArray : opts.useTArray), | ||
colorTransform: (typeof opts.colorTransform === 'undefined' ? | ||
defaultOpts.colorTransform : opts.colorTransform) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: ;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
thanks @skogsbaer! |
Currently, the cornerstoneWADOImageLoader library uses an internal and outdated copy of jpeg-js (for historical reasons). We want now to use the jpeg-js library directly.
This PR adds support for skipping the color transformation (cornerstoneWADOImageLoader does its own)
We also need support for 16bit JPEGs. The cornerstoneWADOImageLoader has a getData16 function for this purpose (see https://github.com/cornerstonejs/cornerstoneWADOImageLoader/blob/master/codecs/jpeg.js). What would be the best way to bring support for 16bit JPEGs to jpeg-js? Just copy get getData16 function?