https://github.com/verifytests/verify.imagemagick
Extends Verify to allow verification of documents via ImageMagick.NET.
https://github.com/verifytests/verify.imagemagick
Last synced: 2 months ago
JSON representation
Extends Verify to allow verification of documents via ImageMagick.NET.
- Host: GitHub
- URL: https://github.com/verifytests/verify.imagemagick
- Owner: VerifyTests
- License: mit
- Created: 2020-02-24T00:00:36.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2025-04-14T11:25:48.000Z (about 1 year ago)
- Last Synced: 2025-04-14T12:29:41.799Z (about 1 year ago)
- Language: C#
- Homepage:
- Size: 2.56 MB
- Stars: 5
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- Funding: .github/FUNDING.yml
- License: license.txt
- Code of conduct: code_of_conduct.md
Awesome Lists containing this project
README
#
Verify.ImageMagick
[](https://github.com/orgs/VerifyTests/discussions)
[](https://ci.appveyor.com/project/SimonCropp/Verify-ImageMagick)
[](https://www.nuget.org/packages/Verify.ImageMagick/)
Extends [Verify](https://github.com/VerifyTests/Verify) to allow verification of documents via [Magick.NET](https://github.com/dlemstra/Magick.NET).
**See [Milestones](../../milestones?state=closed) for release notes.**
Converts documents pdfs to png for verification.
Contains [comparers](https://github.com/VerifyTests/Verify/blob/master/docs/comparer.md) for png, jpg, bmp, and tiff.
## Sponsors
### Entity Framework Extensions
[Entity Framework Extensions](https://entityframework-extensions.net/?utm_source=simoncropp&utm_medium=Verify.ImageMagick) is a major sponsor and is proud to contribute to the development this project.
[](https://entityframework-extensions.net/?utm_source=simoncropp&utm_medium=Verify.ImageMagick)
### Developed using JetBrains IDEs
[](https://jb.gg/OpenSourceSupport)
## NuGet
* https://nuget.org/packages/Verify.ImageMagick
## Usage
```cs
[ModuleInitializer]
public static void Init()
{
VerifyImageMagick.Initialize();
VerifyImageMagick.RegisterComparers(threshold: 0.5);
}
```
snippet source | anchor
`Initialize` registers the pdf to png converter and all comparers.
### PDF converter
To register only the pdf to png converter:
```
VerifyImageMagick.RegisterPdfToPngConverter();
```
#### Verify a file
```cs
[Test]
public Task VerifyPdf() =>
VerifyFile("sample.pdf");
```
snippet source | anchor
#### Verify a Stream
```cs
[Test]
public Task VerifyPdfStream()
{
var stream = new MemoryStream(File.ReadAllBytes("sample.pdf"));
return Verify(stream, "pdf");
}
```
snippet source | anchor
#### Result
[Samples.VerifyPdf#00.verified.png](/src/Tests/Samples.VerifyPdf#00.verified.png):

### Image Comparers
The following will use ImageMagick to compare the images instead of the default binary comparison.
```cs
[Test]
public Task CompareImage() =>
VerifyFile("sample.jpg");
```
snippet source | anchor
### Register all comparers
All comparers can be registered:
```
VerifyImageMagick.RegisterComparers();
```
### Override transparent background
For images with a transparent background, that background can be overridden:
```cs
[Test]
public Task BackgroundColor() =>
VerifyFile("transparent.png")
.ImageMagickBackground(MagickColors.Blue);
```
snippet source | anchor
### Open password-protected PDFs
For password-protected PDF, the password can be provided to allow verification:
```cs
[Test]
public Task PdfPassword() =>
VerifyFile("password.pdf")
.ImageMagickPdfPassword("password");
```
snippet source | anchor
## Icon
[Swirl](https://thenounproject.com/term/wizard/2744075/) designed by [Philipp Petzka](https://thenounproject.com/masteroficon) from [The Noun Project](https://thenounproject.com/).