ImageBox 1.0.1
dotnet add package ImageBox --version 1.0.1
NuGet\Install-Package ImageBox -Version 1.0.1
<PackageReference Include="ImageBox" Version="1.0.1" />
paket add ImageBox --version 1.0.1
#r "nuget: ImageBox, 1.0.1"
// Install ImageBox as a Cake Addin #addin nuget:?package=ImageBox&version=1.0.1 // Install ImageBox as a Cake Tool #tool nuget:?package=ImageBox&version=1.0.1
image-box
A C# API for creating PNGs and GIFs from vue-like templates
Installation
You can install the NuGet package:
PM> Install-Package ImageBox
Setup
You can either add the ImageBox library to your project using either Dependency Injection or by using the ImageBoxUtility
class.
Usage
This is the preferred method of using this library as it gives you more control how the library is used. You can add the ImageBox library to your services like so:
using ImageBox;
//Get these from your application
IConfiguration config;
IServiceCollection services;
//Register the ImageBox library with your services
services.AddImageBox(config);
...
using ImageBox;
//Fetch this from your services
IImageBoxService _imageBox;
//Get your template and image output paths
var template = "template.html";
var outputDir = "output";
var outputName = "some-image";
//Get the image context and services
var image = _imageBox.Create(template);
var context = await _imageBox.LoadContext(image);
//Determine the output path
var outputExt = context.Animate ? "gif" : "png";
var outputPath = Path.Combine(outputDir, $"{outputName}.{outputExt}");
//Render the image
await _imageBox.Render(ouputPath, image);
You can see an example of this method in the ImageBox.Cli
project.
ImageBoxUtility
You can use the ImageBoxUtility
class to create images like so:
using ImageBox;
var inputPath = "template.html";
var outputPath = "output.gif";
var ib = ImageBoxUtility.From(inputPath);
await ib.Render(outputPath);
Examples
You can check the various examples used in the ImageBox.Cli
project.
More documentation will be added soon.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net8.0
- CardboardBox.Http (>= 2.0.2)
- CardboardBox.Json (>= 1.0.2)
- CardboardBox.Setup (>= 2.0.0)
- HtmlAgilityPack (>= 1.11.63)
- Jint (>= 4.0.1)
- SixLabors.ImageSharp.Drawing (>= 2.1.4)
- Svg (>= 3.4.7)
- System.Security.Cryptography.Pkcs (>= 8.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.