Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports.diffImagesWithDimensions = function(actualTile, expectedTilePath, width, height, callback) {
if (typeof(process) !== 'undefined' && process.version) {
var chunkStream = new Duplex();
chunkStream.push(actualTile);
chunkStream.push(null);
pureimage.decodePNGFromStream(chunkStream).then(function(actualImage) {
pureimage.decodePNGFromStream(fs.createReadStream(expectedTilePath)).then(function(expectedImage) {
var same = true;
for (var x = 0; x < actualImage.width && same; x++) {
for (var y = 0; y < actualImage.height && same; y++) {
var actualRGBA = actualImage.getPixelRGBA(x,y);
var expectedRGBA = expectedImage.getPixelRGBA(x,y);
same = actualRGBA === expectedRGBA;
}
}
callback(null, same);
});
});
} else {
if (actualTile instanceof Uint8Array) {
var binary = '';
var bytes = actualTile;
pureimage.decodePNGFromStream(chunkStream).then(function(actualImage) {
pureimage.decodePNGFromStream(fs.createReadStream(expectedTilePath)).then(function(expectedImage) {
var same = true;
for (var x = 0; x < actualImage.width && same; x++) {
for (var y = 0; y < actualImage.height && same; y++) {
var actualRGBA = actualImage.getPixelRGBA(x,y);
var expectedRGBA = expectedImage.getPixelRGBA(x,y);
same = actualRGBA === expectedRGBA;
}
}
callback(null, same);
});
});
} else {
export async function trayIconBundleFromPath(trayIconPath: string): Promise {
const bitmap = await decodePNGFromStream(createReadStream(trayIconPath));
return {
bitmap,
native: await bitmapToNativeImage(bitmap),
};
}