forked from lovell/sharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement brightness, saturation and hue modulation lovell#609
- Loading branch information
Showing
13 changed files
with
108 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
'use strict'; | ||
|
||
const sharp = require('../../'); | ||
const fixtures = require('../fixtures'); | ||
|
||
describe.only('Modulate', function () { | ||
it('should be able to hue-rotate', function (done) { | ||
sharp(fixtures.inputJpg) | ||
.modulate({ hue: 120 }) | ||
.toBuffer(function (err, data, info) { | ||
if (err) throw err; | ||
fixtures.assertSimilar(fixtures.expected('modulate-hue-120.jpg'), data, { threshold: 1 }, done); | ||
}); | ||
}); | ||
|
||
it('should be able to brighten', function (done) { | ||
sharp(fixtures.inputJpg) | ||
.modulate({ brightness: 2 }) | ||
.toBuffer(function (err, data, info) { | ||
if (err) throw err; | ||
require('fs').writeFileSync('./modulate-brightness-2.jpg.jpg', data); | ||
fixtures.assertSimilar(fixtures.expected('modulate-brightness-2.jpg'), data, { threshold: 1 }, done); | ||
}); | ||
}); | ||
|
||
it('should be able to unbrighten', function (done) { | ||
sharp(fixtures.inputJpg) | ||
.modulate({ brightness: 0.5 }) | ||
.toBuffer(function (err, data, info) { | ||
if (err) throw err; | ||
require('fs').writeFileSync('./modulate-brightness-0-5.jpg', data); | ||
fixtures.assertSimilar(fixtures.expected('modulate-brightness-0-5.jpg'), data, { threshold: 1 }, done); | ||
}); | ||
}); | ||
|
||
it('should be able to saturate', function (done) { | ||
sharp(fixtures.inputJpg) | ||
.modulate({ saturation: 2 }) | ||
.toBuffer(function (err, data, info) { | ||
if (err) throw err; | ||
require('fs').writeFileSync('./modulate-saturation-2.jpg.jpg', data); | ||
fixtures.assertSimilar(fixtures.expected('modulate-saturation-2.jpg'), data, { threshold: 1 }, done); | ||
}); | ||
}); | ||
|
||
it('should be able to desaturate', function (done) { | ||
sharp(fixtures.inputJpg) | ||
.modulate({ saturation: 0.5 }) | ||
.toBuffer(function (err, data, info) { | ||
if (err) throw err; | ||
require('fs').writeFileSync('./modulate-saturation-0-5.jpg', data); | ||
fixtures.assertSimilar(fixtures.expected('modulate-saturation-0-5.jpg'), data, { threshold: 1 }, done); | ||
}); | ||
}); | ||
|
||
it('should be able to modulate all channels', function (done) { | ||
sharp(fixtures.inputJpg) | ||
.modulate({ brightness: 2, saturation: 0.5, hue: 180 }) | ||
.toBuffer(function (err, data, info) { | ||
if (err) throw err; | ||
require('fs').writeFileSync('./modulate-all.jpg', data); | ||
fixtures.assertSimilar(fixtures.expected('modulate-all.jpg'), data, { threshold: 1 }, done); | ||
}); | ||
}); | ||
}); |