looks-same
Advanced tools
Comparing version 2.2.2 to 3.0.0
# Changelog | ||
## 3.0.0 - 2016-07-13 | ||
* Remove support for 0.10 and 0.12 NodeJS versions. | ||
* Fix ignore caret on devices with `pixelRatio` > 1. | ||
* Fix bug with the missed 1px diff between images when `ignoreCaret` option is enabled. | ||
## 2.2.2 - 2015-12-19 | ||
@@ -4,0 +10,0 @@ |
23
index.js
'use strict'; | ||
var parseColor = require('parse-color'), | ||
colorDiff = require('color-diff'), | ||
png = require('./png'); | ||
png = require('./lib/png'), | ||
IgnoreCaretComparator = require('./lib/ignore-caret-comparator'); | ||
@@ -73,3 +74,3 @@ var JND = 2.3; //Just noticable difference | ||
if (opts.ignoreCaret) { | ||
comparator = makeNoCaretColorComparator(comparator); | ||
comparator = makeNoCaretColorComparator(comparator, opts.pixelRatio); | ||
} | ||
@@ -80,17 +81,5 @@ | ||
function makeNoCaretColorComparator(comparator) { | ||
var prevFailure = null; | ||
return function compareNoCaret(color1, color2, x, y) { | ||
if (comparator(color1, color2, x, y)) { | ||
return true; | ||
} | ||
if (prevFailure) { | ||
if (x !== prevFailure.x || y !== prevFailure.y + 1) { | ||
return false; | ||
} | ||
} | ||
prevFailure = {x: x, y: y}; | ||
return true; | ||
}; | ||
function makeNoCaretColorComparator(comparator, pixelRatio) { | ||
const caretComparator = new IgnoreCaretComparator(comparator, pixelRatio); | ||
return (color1, color2, x, y) => caretComparator.compare(color1, color2, x, y); | ||
} | ||
@@ -97,0 +86,0 @@ |
{ | ||
"name": "looks-same", | ||
"version": "2.2.2", | ||
"version": "3.0.0", | ||
"description": "Pure node.js library for comparing PNG-images, taking into account human color perception.", | ||
@@ -26,2 +26,5 @@ "main": "index.js", | ||
}, | ||
"engines": { | ||
"node": ">= 4.0" | ||
}, | ||
"author": "Sergey Tatarintsev <sevinf@yandex-team.ru> (https://github.com/SevInf)", | ||
@@ -28,0 +31,0 @@ "license": "MIT", |
@@ -56,2 +56,12 @@ # LooksSame | ||
Some devices can have different proportion between physical and logical screen resolutions also | ||
known as `pixel ratio`. Default value for this proportion is 1. | ||
This param also affects the comparison result, so it can be set manually with `pixelRatio` option. | ||
```javascript | ||
looksSame('image1.png', 'image2.png', {pixelRatio: 2}, function(error, equal) { | ||
... | ||
}); | ||
``` | ||
## Building diff image | ||
@@ -58,0 +68,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
62474
27
494
105
1