Skip to content

Feature request: Expose writeImages's combinePages option as a new CompareOption #97

@EvHaus

Description

@EvHaus

The writeImages function in this library has a combinePages argument which is set to true by default. Could you please expose control over this in CompareOptions so that I can set it to false for my usecase?

In my case I'm doing a comparison of a giant 200 page PDF and reviewing the diff of a 150,000px tall PNG is really difficult, whereas reviewing the diff page-by-page would be really lovely.

For now, I'm using this pnpm patch to handle this behaviour. It works great! It would be lovely if the library could support this natively though:

@@ -0,0 +1,24 @@
diff --git a/lib/compare-pdf-to-snapshot.js b/lib/compare-pdf-to-snapshot.js
index c0b8f24a5f35a9f2f2e65a8e06c5bb7047c5ce33..1dce7b4172699930956b22719175259fef9c5519 100644
--- a/lib/compare-pdf-to-snapshot.js
+++ b/lib/compare-pdf-to-snapshot.js
@@ -108,7 +108,7 @@ async function handleMissingSnapshot(pdf, snapshotContext, { failOnMissingSnapsh
     }
     // Generate snapshot if missing
     const images = await (0, pdf2png_1.pdf2png)(pdf, pdf2PngOptions).then(maskImgWithRegions(maskRegions));
-    await (0, imageUtils_1.writeImages)(snapshotContext.path)(images);
+    await (0, imageUtils_1.writeImages)(snapshotContext.path, false)(images);
     return true;
 }
 async function compareWithSnapshot(pdf, snapshotContext, { maskRegions, pdf2PngOptions, tolerance }) {
@@ -119,8 +119,8 @@ async function compareWithSnapshot(pdf, snapshotContext, { maskRegions, pdf2PngO
         await removeIfExists(snapshotContext.newPath);
         return true;
     }
-    await (0, imageUtils_1.writeImages)(snapshotContext.newPath)(images);
-    await (0, imageUtils_1.writeImages)(snapshotContext.diffPath)(result.diffs.map((x) => x.diff));
+    await (0, imageUtils_1.writeImages)(snapshotContext.newPath, false)(images);
+    await (0, imageUtils_1.writeImages)(snapshotContext.diffPath, false)(result.diffs.map((x) => x.diff));
     return false;
 }
 async function removeIfExists(filePath) {

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions