UNPKG

pdf-visual-diff

Version:

Visual Regression Testing for PDFs in JavaScript

23 lines 841 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.mergeImages = mergeImages; const jimp_1 = require("jimp"); /** * Merges an array of Jimp images into a single image. * * @param images - An array of Jimp images to be merged. * @returns A Jimp image that is the result of merging all input images. */ function mergeImages(images) { let imgHeight = 0; const imgData = images.map((img) => { const res = { img, y: imgHeight }; imgHeight += img.height; return res; }); const imgWidth = Math.max(...imgData.map(({ img }) => img.width)); const baseImage = new jimp_1.Jimp({ width: imgWidth, height: imgHeight, color: 0x00000000 }); imgData.forEach(({ img, y }) => baseImage.composite(img, 0, y)); return baseImage; } //# sourceMappingURL=mergeImages.js.map