Skip to content

Commit

Permalink
Add cyan and red color options, rename pink to magenta.
Browse files Browse the repository at this point in the history
  • Loading branch information
blueimp committed Dec 8, 2016
1 parent 8f5312f commit 21be348
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ imgDiff(
similarity: 0.01, // 1.0 - 0.01
blend: 1.0, // 1.0 - 0.0
opacity: 0.1, // 1.0 - 0.0
color: 'pink' // pink, yellow, green, blue or ''
color: 'magenta' // magenta, yellow, cyan, red green, blue or ''
}
).then((ssim) => {
console.log(ssim)
Expand Down Expand Up @@ -77,8 +77,8 @@ Higher values result in a more opaque background image.
### color
The color balance of the differential pixels.
An empty string displays the default differential pixels.
*Set:* `['pink', 'yellow', 'green', 'blue', '']`
*Default:* `'pink'`
*Set:* `['magenta', 'yellow', 'cyan', 'red', 'green', 'blue', '']`
*Default:* `'magenta'`

## Samples

Expand Down
10 changes: 8 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ module.exports = function (refImg, cmpImg, outImg, opts) {
similarity: 0.01, // 1.0 - 0.01
blend: 1.0, // 1.0 - 0.0
opacity: 0.1, // 1.0 - 0.0
color: 'pink' // pink, yellow, green, blue, '', or FFmpeg colorbalance
color: 'magenta' // magenta, yellow, cyan, red green, blue or ''
}
if (opts) Object.assign(options, opts)
const ssim = options.ssim
Expand All @@ -74,12 +74,18 @@ module.exports = function (refImg, cmpImg, outImg, opts) {
`:similarity=${options.similarity}:blend=${options.blend}`
let colorbalance = 'colorbalance='
switch (options.color) {
case 'pink':
case 'magenta':
colorbalance += `rs=1:gs=-1:bs=1:rm=1:gm=-1:bm=1:rh=1:gh=-1:bh=1`
break
case 'yellow':
colorbalance += `rs=1:gs=1:bs=-1:rm=1:gm=1:bm=-1:rh=1:gh=1:bh=-1`
break
case 'cyan':
colorbalance += `rs=-1:gs=1:bs=1:rm=-1:gm=1:bm=1:rh=-1:gh=1:bh=1`
break
case 'red':
colorbalance += `rs=1:gs=-1:bs=-1:rm=1:gm=-1:bm=-1:rh=1:gh=-1:bh=-1`
break
case 'green':
colorbalance += `rs=-1:gs=1:bs=-1:rm=-1:gm=1:bm=-1:rh=-1:gh=1:bh=-1`
break
Expand Down
4 changes: 3 additions & 1 deletion test/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ function test (outImg, options) {
}

test() // SSIM only
.then(() => test('out.png')) // Default options (color: 'pink')
.then(() => test('out.png')) // Default options (color: 'magenta')
.then(() => test('out-color-yellow.png', {color: 'yellow'}))
.then(() => test('out-color-cyan.png', {color: 'cyan'}))
.then(() => test('out-color-red.png', {color: 'red'}))
.then(() => test('out-color-green.png', {color: 'green'}))
.then(() => test('out-color-blue.png', {color: 'blue'}))
.then(() => test('out-color-empty.png', {color: ''}))
Expand Down

0 comments on commit 21be348

Please sign in to comment.