resemblejs
Advanced tools
Comparing version 2.2.6 to 2.5.0
{ | ||
"name": "resemblejs", | ||
"version": "2.2.6", | ||
"version": "2.5.0", | ||
"description": "Image analysis and comparison with HTML5", | ||
@@ -25,4 +25,4 @@ "main": "resemble.js", | ||
"scripts": { | ||
"test": "jest ./nodejs-tests", | ||
"test-watch": "jest --watch ./nodejs-tests" | ||
"test": "jest nodejs-tests", | ||
"test-watch": "jest --watch nodejs-tests" | ||
}, | ||
@@ -32,7 +32,6 @@ "devDependencies": { | ||
"jest": "^20.0.4", | ||
"jest-cli": "^20.0.4" | ||
"jest-cli": "^20.0.4", | ||
"canvas-prebuilt": "^1.6.5-prerelease.1", | ||
"color-convert": "^1.9.0" | ||
}, | ||
"peerDependencies": { | ||
"canvas": "^1.6.5" | ||
}, | ||
"jest": { | ||
@@ -39,0 +38,0 @@ "testEnvironment": "node" |
@@ -59,2 +59,3 @@ Resemble.js | ||
// diff.ignoreColors(); | ||
// diff.ignoreAlpha(); | ||
diff.ignoreAntialiasing(); | ||
@@ -76,3 +77,4 @@ ``` | ||
largeImageThreshold: 1200, | ||
useCrossOrigin: false | ||
useCrossOrigin: false, | ||
outputDiff: true | ||
}); | ||
@@ -123,4 +125,6 @@ // resembleControl.repaint(); | ||
``` js | ||
const compareImage = require('resemblejs/compareImages'); | ||
const compareImages = require('resemblejs/compareImages'); | ||
const fs = require("fs"); | ||
async function getDiff(){ | ||
// The parameters can be Node Buffers | ||
@@ -134,2 +138,7 @@ // data is the same as usual with an additional getBuffer() function | ||
fs.writeFileSync('./output.png', data.getBuffer()); | ||
} | ||
getDiff(); | ||
``` | ||
@@ -136,0 +145,0 @@ |
@@ -69,2 +69,8 @@ /* | ||
px[offset + 3] = d2.a; | ||
}, | ||
diffOnly: function (px, offset, d1, d2) { | ||
px[offset] = d2.r; | ||
px[offset + 1] = d2.g; | ||
px[offset + 2] = d2.b; | ||
px[offset + 3] = d2.a; | ||
} | ||
@@ -74,2 +80,3 @@ }; | ||
var errorPixel = errorPixelTransform.flat; | ||
var errorType; | ||
var boundingBox; | ||
@@ -81,3 +88,3 @@ var largeImageThreshold = 1200; | ||
// This will work as long as only createElement is used on window.document | ||
var Canvas = require('canvas'); | ||
var Canvas = require('canvas-prebuilt'); | ||
return new Canvas(); | ||
@@ -179,3 +186,3 @@ } | ||
} else { | ||
var CanvasImage = require('canvas').Image; | ||
var CanvasImage = require('canvas-prebuilt').Image; | ||
hiddenImage = new CanvasImage(); | ||
@@ -374,2 +381,6 @@ hiddenImage.setAttribute = function setAttribute() { }; | ||
function copyPixel(px, offset, data){ | ||
if (errorType === 'diffOnly') { | ||
return; | ||
} | ||
px[offset] = data.r; //r | ||
@@ -382,2 +393,6 @@ px[offset + 1] = data.g; //g | ||
function copyGrayScalePixel(px, offset, data){ | ||
if (errorType === 'diffOnly') { | ||
return; | ||
} | ||
px[offset] = data.brightness; //r | ||
@@ -522,4 +537,12 @@ px[offset + 1] = data.brightness; //g | ||
if (hiddenCanvas.toBuffer) { | ||
data.getBuffer = function() { | ||
context.putImageData(imgd, 0, 0); | ||
data.getBuffer = function(includeOriginal) { | ||
if (includeOriginal) { | ||
var imageWidth = hiddenCanvas.width + 2; | ||
hiddenCanvas.width = imageWidth * 3; | ||
context.putImageData(img1, 0, 0); | ||
context.putImageData(img2, imageWidth, 0); | ||
context.putImageData(imgd, imageWidth * 2, 0); | ||
} else { | ||
context.putImageData(imgd, 0, 0); | ||
} | ||
return hiddenCanvas.toBuffer(); | ||
@@ -687,2 +710,17 @@ } | ||
}, | ||
ignoreAlpha: function() { | ||
tolerance.red = 16; | ||
tolerance.green = 16; | ||
tolerance.blue = 16; | ||
tolerance.alpha = 255; | ||
tolerance.minBrightness = 16; | ||
tolerance.maxBrightness = 240; | ||
ignoreAntialiasing = false; | ||
ignoreColors = false; | ||
if(hasMethod) { param(); } | ||
return self; | ||
}, | ||
repaint: function(){ | ||
@@ -735,2 +773,3 @@ if(hasMethod) { param(); } | ||
errorPixel = errorPixelTransform[options.errorType]; | ||
errorType = options.errorType; | ||
} | ||
@@ -737,0 +776,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
0
164
0
70055
5
15
643