Make contrast behave more like CSS/Photoshop legacy constrast #658
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What's Changing and Why
The
contrast
function in thecolor
package was modified to behave more like the CSS contrast filter or Photoshop's legacy contrast mode (eg negative values move towards mid gray, positive values push colors near mid to their dark/light extremes)What else might be affected
Nothing else in Jimp uses the
contrast
function, so theoretically, nothing.Tasks
It appears that there are not currently any tests for
contrast
.Was going to add some, but could not get Jimp to clean/build/run tests etc on Windows after cloning and doing NPM install - someone may want to look into cross platform testing, whether all build/clean/test dependencies are correctly installed etc. - I did notice some *nix shell specific things like
rf
in thereHowever I have manually verified by eye that an image adjusted with this algorithm from -1 to 1 by increments of 0.1 looks correct compared to both Photoshop and CSS
Somebody on whose system Jimp does correctly build should do a sanity check before merging this branch though, just to be sure that I haven't broken anything, unlikely though it seems.
contrast
does not change from the user's point of view, no changes to documentation neededjimp.d.ts
All changes are internal to the
contrast
function, not required