Skip to content

Commit 4e85d2a

Browse files
authored
add webp support (#758)
1 parent 471e81f commit 4e85d2a

6 files changed

Lines changed: 11 additions & 2 deletions

File tree

src/.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*.pdf binary
55
*.png binary
66
*.tiff binary
7+
*.webp binary
78

89
*.verified.txt text eol=lf working-tree-encoding=UTF-8
910
*.verified.xml text eol=lf working-tree-encoding=UTF-8

src/Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<Project>
33
<PropertyGroup>
44
<NoWarn>CS1591;CS0649;NU1608;NU1109</NoWarn>
5-
<Version>3.7.7</Version>
5+
<Version>3.8.0</Version>
66
<AssemblyVersion>1.0.0</AssemblyVersion>
77
<ImplicitUsings>enable</ImplicitUsings>
88
<LangVersion>preview</LangVersion>
173 KB
Loading

src/Tests/Tests.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ public Task CompareDifferent()
5656
public Task VerifyPdf() =>
5757
VerifyFile("sample.pdf");
5858

59+
[Test]
60+
public Task VerifyWebp() =>
61+
VerifyFile("sample.webp");
62+
5963
[Test]
6064
public Task VerifyPdfWithName() =>
6165
Verify(targets: [new("pdf", File.OpenRead("sample.pdf"), "name")]);

src/Tests/sample.webp

173 KB
Loading

src/Verify.ImageMagick/VerifyImageMagick.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ public static void Initialize()
2121
VerifierSettings.RegisterStreamConverter(
2222
"png",
2323
(name, stream, context) => ConvertImage(name, stream, context, "png", MagickFormat.Png));
24+
VerifierSettings.RegisterStreamConverter(
25+
"webp",
26+
(name, stream, context) => ConvertImage(name, stream, context, "webp", MagickFormat.WebP));
2427
VerifierSettings.RegisterStreamConverter(
2528
"tiff",
2629
(name, stream, context) => ConvertImage(name, stream, context, "tiff", MagickFormat.Tiff));
@@ -61,6 +64,7 @@ public static void RegisterComparers(double threshold = .005, ErrorMetric metric
6164
RegisterComparer(threshold, metric, "jpg");
6265
RegisterComparer(threshold, metric, "bmp");
6366
RegisterComparer(threshold, metric, "tiff");
67+
RegisterComparer(threshold, metric, "webp");
6468
VerifierSettings.RegisterStringComparer(
6569
"svg",
6670
(received, verified, _) => CompareSvg(threshold, metric, received, verified));
@@ -97,7 +101,7 @@ internal static Task<CompareResult> Compare(double threshold, ErrorMetric metric
97101
public static void ImageMagickComparer(this VerifySettings settings, double threshold = .005, ErrorMetric metric = ErrorMetric.Fuzz) =>
98102
settings.UseStreamComparer(
99103
(received, verified, _) => Compare(threshold, metric, received, verified),
100-
extensions: ["png", "jpg", "bmp", "tiff"]);
104+
extensions: ["png", "jpg", "bmp", "tiff", "webp"]);
101105

102106
/// <summary>
103107
/// Helper method that calls <see cref="RegisterPdfToPngConverter"/> and

0 commit comments

Comments
 (0)