AnointedAutomation.Imaging
1.0.5
dotnet add package AnointedAutomation.Imaging --version 1.0.5
NuGet\Install-Package AnointedAutomation.Imaging -Version 1.0.5
<PackageReference Include="AnointedAutomation.Imaging" Version="1.0.5" />
<PackageVersion Include="AnointedAutomation.Imaging" Version="1.0.5" />
<PackageReference Include="AnointedAutomation.Imaging" />
paket add AnointedAutomation.Imaging --version 1.0.5
#r "nuget: AnointedAutomation.Imaging, 1.0.5"
#:package AnointedAutomation.Imaging@1.0.5
#addin nuget:?package=AnointedAutomation.Imaging&version=1.0.5
#tool nuget:?package=AnointedAutomation.Imaging&version=1.0.5
AnointedAutomation.Imaging
Jesus is King ✝️
Image generation utilities for the AnointedAutomation suite. It renders QR codes produced by AnointedAutomation.Algorithms to SVG or PNG using only the .NET base class library, so there is no third party or native image dependency.
Installation
dotnet add package AnointedAutomation.Imaging
- Target framework:
net10.0 - Dependencies: AnointedAutomation.Algorithms (installed automatically; provides
QrEncoderandQrMatrix)
Quick start
using System.IO;
using AnointedAutomation.Algorithms.QrCode;
using AnointedAutomation.Imaging.QrCode;
QrMatrix matrix = QrEncoder.Encode("https://store.anointed.company", QrErrorCorrectionLevel.M);
string svg = QrRenderer.ToSvg(matrix, moduleSize: 8, quietZone: 4);
byte[] png = QrRenderer.ToPng(matrix, moduleSize: 8, quietZone: 4);
File.WriteAllText("qr.svg", svg);
File.WriteAllBytes("qr.png", png);
API overview
Namespace: AnointedAutomation.Imaging.QrCode
| Member | Returns | Description |
|---|---|---|
QrRenderer.ToSvg(QrMatrix matrix, int moduleSize = 8, int quietZone = 4) |
string |
An SVG document with a white background and one black rect per dark module, drawn with shape-rendering="crispEdges". |
QrRenderer.ToPng(QrMatrix matrix, int moduleSize = 8, int quietZone = 4) |
byte[] |
An 8 bit grayscale PNG, compressed with the BCL ZLibStream. |
Parameters:
moduleSize: pixel size of each module. Must be at least 1.quietZone: width of the light border, in modules. Must be 0 or more; the QR specification recommends 4.- The output image is
(matrix.Size + 2 * quietZone) * moduleSizepixels square.
Both methods throw ArgumentNullException for a null matrix and ArgumentOutOfRangeException for an invalid moduleSize or quietZone.
Serving a QR code from ASP.NET Core
// Program.cs in an ASP.NET Core project (Microsoft.NET.Sdk.Web)
using AnointedAutomation.Algorithms.QrCode;
using AnointedAutomation.Imaging.QrCode;
WebApplication app = WebApplication.CreateBuilder(args).Build();
app.MapGet("/qr", (string text) =>
{
QrMatrix matrix = QrEncoder.Encode(text, QrErrorCorrectionLevel.Q);
return Results.File(QrRenderer.ToPng(matrix), "image/png");
});
app.Run();
Related packages
- AnointedAutomation.Algorithms: the QR encoder that produces the
QrMatrixthis package renders.
License
MIT. See LICENSE. Copyright © Anointed Automation Corporation. Stewarded by Alexander Fields.
Support This Project
This library is free and open source. The best way to support the work is to shop with us:
- Christian items: https://store.anointed.company
- Pets: https://www.animaldander.com
- Everything else: https://www.mart.club
Found a bug or have a request? Open an issue: https://github.com/AnointedAutomation/AnointedAutomation/issues
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- AnointedAutomation.Algorithms (>= 1.0.5)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.