-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Added .linear(a, b) operation for levels adjustment #742
Conversation
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.
Hi Brandon, thank you for this well-written PR. I've made a couple of minor comments inline.
* @throws {Error} Invalid parameters | ||
*/ | ||
const linear = function linear (a, b) { | ||
if (!is.defined(linear)) { |
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.
Did you mean to check a
and/or b
here?
this.options.linearA = a; | ||
this.options.linearB = b; | ||
} else { | ||
throw new Error('Invalid linear arguments ' + a + ',' + b); |
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.
ES6 template literals are "allowed" if you'd like to use them here :)
const fixtures = require('../fixtures'); | ||
|
||
describe('Linear adjustment', function () { | ||
it('applies levels adjustment', function (done) { |
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.
Are you able to add a test for the code path that removes/rejoins the alpha channel?
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.
Oh, and a test for the throwing of "Invalid linear arguments" please.
Feel free to add yourself to the contributors list also! |
This PR has formed the basis of another PR - see #1024 |
Superseded by #1024 - thank you for taking the time to submit this PR - I expect this feature to ship in v0.19.0. |
This just exposes the libvips'
linear
method which is useful when you need to do a manual levels adjustment and not use the more automaticnormalize
method.