Extends Verify to allow verification of documents via Magick.NET.
See Milestones for release notes.
Converts documents pdfs to png for verification.
Contains comparers for png, jpg, bmp, and tiff.
Entity Framework Extensions is a major sponsor and is proud to contribute to the development this project.
[ModuleInitializer]
public static void Init()
{
VerifyImageMagick.Initialize();
VerifyImageMagick.RegisterComparers(threshold: 0.5);
}Initialize registers the pdf to png converter and all comparers.
Initialize accepts an optional ImageMagickOutputs flags enum that controls, globally, which outputs a document is split into:
Png: render pdf pages and svg documents to png.None: none of the above. Only the source document is emitted.All: all of the above. This is the default.
Omitted outputs are skipped before any rendering, so no work is done for them. The source document target (pdf or svg) is always emitted; use VerifierSettings.ExcludeTargets("pdf") to exclude it. Png, webp, and tiff image files are not affected. To emit only the source document, pass ImageMagickOutputs.None:
[ModuleInitializer]
public static void Init() =>
// Only emit the source document. Skip rendering to png.
VerifyImageMagick.Initialize(ImageMagickOutputs.None);To register only the pdf to png converter:
VerifyImageMagick.RegisterPdfToPngConverter();
[Test]
public Task VerifyPdf() =>
VerifyFile("sample.pdf");[Test]
public Task VerifyPdfStream()
{
var stream = new MemoryStream(File.ReadAllBytes("sample.pdf"));
return Verify(stream, "pdf");
}Samples.VerifyPdf#00.verified.png:
The following will use ImageMagick to compare the images instead of the default binary comparison.
[Test]
public Task CompareImage() =>
VerifyFile("sample.jpg");All comparers can be registered:
VerifyImageMagick.RegisterComparers();
For images with a transparent background, that background can be overridden:
[Test]
public Task BackgroundColor() =>
VerifyFile("transparent.png")
.ImageMagickBackground(MagickColors.Blue);For password-protected PDF, the password can be provided to allow verification:
[Test]
public Task PdfPassword() =>
VerifyFile("password.pdf")
.ImageMagickPdfPassword("password")
.ExcludeTargets("pdf");Swirl designed by Philipp Petzka from The Noun Project.


