VeeFriends.ImageEncoder 1.0.21

dotnet add package VeeFriends.ImageEncoder --version 1.0.21                
NuGet\Install-Package VeeFriends.ImageEncoder -Version 1.0.21                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="VeeFriends.ImageEncoder" Version="1.0.21" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add VeeFriends.ImageEncoder --version 1.0.21                
#r "nuget: VeeFriends.ImageEncoder, 1.0.21"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install VeeFriends.ImageEncoder as a Cake Addin
#addin nuget:?package=VeeFriends.ImageEncoder&version=1.0.21

// Install VeeFriends.ImageEncoder as a Cake Tool
#tool nuget:?package=VeeFriends.ImageEncoder&version=1.0.21                

VeeFriends Avatar Data Encoder/Decoder

This package has nothing to do with Gary Vaynerchuk.

Nuget

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.21 23,417 5/20/2024
1.0.20 95 5/16/2024
1.0.19 106 5/16/2024
1.0.18 588 5/16/2024
1.0.17 96 5/16/2024
1.0.16 106 5/16/2024
1.0.15 100 5/16/2024
1.0.14 104 5/16/2024
1.0.13 99 5/16/2024
1.0.12 102 5/16/2024