VeeFriends.ImageEncoder
1.0.18
See the version list below for details.
dotnet add package VeeFriends.ImageEncoder --version 1.0.18
NuGet\Install-Package VeeFriends.ImageEncoder -Version 1.0.18
<PackageReference Include="VeeFriends.ImageEncoder" Version="1.0.18" />
paket add VeeFriends.ImageEncoder --version 1.0.18
#r "nuget: VeeFriends.ImageEncoder, 1.0.18"
// Install VeeFriends.ImageEncoder as a Cake Addin #addin nuget:?package=VeeFriends.ImageEncoder&version=1.0.18 // Install VeeFriends.ImageEncoder as a Cake Tool #tool nuget:?package=VeeFriends.ImageEncoder&version=1.0.18
VeeFriends Avatar Data Encoder/Decoder
This package has nothing to do with Gary Vaynerchuk.
Overview
VeeFriends.ImageEncoder is a C# SDK designed for encoding and decoding hidden data within images. It supports various use cases including encoding data into images from URLs, streams, or OpenSea avatars, and decoding hidden data from these images.
Installation
To install the SDK, add it to your project using NuGet:
dotnet add package VeeFriends.ImageEncoder
Dependency Injection
To use VeeFriends.ImageEncoder with dependency injection, configure the services in your Program.cs
:
using Microsoft.Extensions.DependencyInjection;
using VeeFriends.ImageEncoder;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddVeeFriendsImageEncoder(new()
{
OpenSeaApiKey = "..."
});
var app = builder.Build();
// Configure the HTTP request pipeline.
app.UseAuthorization();
app.MapControllers();
app.Run();
ImageEncoder Class Summary
The ImageEncoder
class provides various methods for encoding and decoding images. Below is a categorized summary of its methods:
Encoding Methods
Encode from URL
ValueTask<Stream> EncodeImage(string urlOfImageToEncode, string codeToEncode, CancellationToken cancellationToken)
ValueTask EncodeImage(string urlOfImageToEncode, string codeToEncode, IAssetUploader assetUploader, CancellationToken cancellationToken)
Encode from Stream
ValueTask<Stream> EncodeImage(Stream imageStream, string codeToEncode, CancellationToken cancellationToken)
ValueTask EncodeImage(Stream imageStream, string codeToEncode, IAssetUploader assetUploader, CancellationToken cancellationToken)
Encode from AssetRetriever
ValueTask<Stream> EncodeImage(IAssetRetriever assetRetriever, string codeToEncode, CancellationToken cancellationToken)
ValueTask EncodeImage(IAssetRetriever assetRetriever, string codeToEncode, IAssetUploader assetUploader, CancellationToken cancellationToken)
Encode OpenSea Avatar
ValueTask<Stream> EncodeOpenSeaAvatar(string walletAddress, string codeToEncode, CancellationToken cancellationToken)
ValueTask EncodeOpenSeaAvatar(string walletAddress, string codeToEncode, IAssetUploader assetUploader, CancellationToken cancellationToken)
Decoding Methods
Decode from URL
ValueTask<string> DecodeImage(string urlOfImageToDecode, CancellationToken cancellationToken)
Decode from Stream
ValueTask<string> DecodeImage(Stream imageStream, CancellationToken cancellationToken)
Decode from AssetRetriever
ValueTask<string> DecodeImage(IAssetRetriever assetRetriever, CancellationToken cancellationToken)
Decode OpenSea Avatar
ValueTask<string> DecodeOpenSeaAvatar(string walletAddress, CancellationToken cancellationToken)
Avatar Generation Methods
Generate Avatar from URL
ValueTask<Stream> GenerateAvatar(string characterImageUrl, CancellationToken cancellationToken)
ValueTask GenerateAvatar(string characterImageUrl, IAssetUploader assetUploader, CancellationToken cancellationToken)
ValueTask<Stream> GenerateAvatar(string characterImageUrl, string codeToEncode, CancellationToken cancellationToken)
ValueTask GenerateAvatar(string characterImageUrl, string codeToEncode, IAssetUploader assetUploader, CancellationToken cancellationToken)
Generate Avatar from AssetRetriever
ValueTask<Stream> GenerateAvatar(IAssetRetriever assetRetriever, CancellationToken cancellationToken)
ValueTask GenerateAvatar(IAssetRetriever assetRetriever, IAssetUploader assetUploader, CancellationToken cancellationToken)
ValueTask<Stream> GenerateAvatar(IAssetRetriever assetRetriever, string codeToEncode, CancellationToken cancellationToken)
ValueTask GenerateAvatar(IAssetRetriever assetRetriever, string codeToEncode, IAssetUploader assetUploader, CancellationToken cancellationToken)
Examples
Encoding an Image from URL
using VeeFriends.ImageEncoder;
using System.Threading;
using System.IO;
using System.Threading.Tasks;
public class Example
{
private readonly ImageEncoder _imageEncoder;
public Example(ImageEncoder imageEncoder)
{
_imageEncoder = imageEncoder;
}
public async Task EncodeImageFromUrl()
{
string imageUrl = "https://example.com/image.jpg";
string codeToEncode = "SecretCode";
CancellationToken cancellationToken = new CancellationToken();
Stream encodedImage = await _imageEncoder.EncodeImage(imageUrl, codeToEncode, cancellationToken);
// Save or use the encodedImage stream
}
}
Decoding an Image from URL
using VeeFriends.ImageEncoder;
using System.Threading;
using System.Threading.Tasks;
public class Example
{
private readonly ImageEncoder _imageEncoder;
public Example(ImageEncoder imageEncoder)
{
_imageEncoder = imageEncoder;
}
public async Task DecodeImageFromUrl()
{
string imageUrl = "https://example.com/encoded-image.jpg";
CancellationToken cancellationToken = new CancellationToken();
string decodedCode = await _imageEncoder.DecodeImage(imageUrl, cancellationToken);
// Use the decodedCode
}
}
Generating and Encoding an Avatar
using VeeFriends.ImageEncoder;
using System.Threading;
using System.IO;
using System.Threading.Tasks;
public class Example
{
private readonly ImageEncoder _imageEncoder;
public Example(ImageEncoder imageEncoder)
{
_imageEncoder = imageEncoder;
}
public async Task GenerateAndEncodeAvatar()
{
string characterImageUrl = "https://example.com/character-image.jpg";
string codeToEncode = "SecretCode";
CancellationToken cancellationToken = new CancellationToken();
Stream encodedAvatar = await _imageEncoder.GenerateAvatar(characterImageUrl, codeToEncode, cancellationToken);
// Save or use the encodedAvatar stream
}
}
License
This project is licensed under the MIT License.
Disclaimer
This SDK uses the ImageSharp library, which is licensed by Six Labors under the terms outlined in their LICENSE.
Key Points:
- License Types:
- Apache License, Version 2.0: For Open Source or Source Available software, Transitive Package Dependencies, Direct Package Dependencies for entities with less than $1M USD annual gross revenue, Non-profits, and Registered Charities.
- Six Labors Commercial License: Required for other commercial use cases.
Please review the full license for detailed terms and conditions.
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
- Microsoft.Extensions.Http (>= 8.0.0)
- SixLabors.ImageSharp (>= 3.1.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.