Skip to content

Repository files navigation

AVIF Generator & Visual Editor

A high-performance, cross-platform desktop application for batch-generating AVIF images with dynamic text overlays. It features a lightweight Web UI for template editing and a blazing-fast, memory-safe backend powered by SkiaSharp and SVT-AV1.

(Placeholder: Add a screenshot of your Fabric.js UI here)

🎬 Demo

(Placeholder: Link to a GIF or YouTube video showing the UI setup and the fast generation process)

✨ Key Features

  • Visual Template Editor: Drag-and-drop web UI (Fabric.js) wrapped in a native lightweight desktop window (Photino.NET). Easily set up text coordinates, bounding boxes, colors, and alignments.
  • Blazing Fast Generation: Achieves up to 9 images per second on modern CPUs using a highly optimized multi-threaded architecture.
  • Memory-Safe Pipeline: Replaced traditional heavy libraries (like ImageMagick) with SkiaSharp for rendering, completely eliminating memory leaks during massive batch runs.
  • Smart Text Rendering: Custom auto-scaling and word-wrap algorithms ensure that dynamic text from CSV files perfectly fits within defined boundaries without overflowing.
  • SVT-AV1 Integration: Utilizes the official avifenc utility with the SVT-AV1 engine, converting standard RGB rendering into highly compressed YUV 4:2:0 AVIF files.

🛠 Tech Stack

  • Core: C#, .NET
  • Desktop App Wrapper: Photino.NET
  • Graphics Engine: SkiaSharp
  • Encoder: avifenc (libavif with SVT-AV1 support)
  • Frontend (UI): HTML/JS, Fabric.js

🚀 Prerequisites

Before running or building the project, ensure you have the following installed:

  1. .NET SDK (version 8.0 or higher).
  2. avifenc executable:
  • Windows: Place avifenc.exe in the root folder of the project or ensure it is in your system's PATH.
  • Linux: Install libavif-bin compiled with SVT-AV1 support.
  1. Fonts (Linux only): If deploying on Linux or Docker, ensure font libraries are installed:
sudo apt-get install fontconfig libfontconfig1 fonts-liberation

📦 Building for Production

The application can be compiled into a single, self-contained executable, removing the need for the end-user to install the .NET runtime.

For Windows (GUI App, no console window):

dotnet publish -c Release -r win-x64 --self-contained true -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true

For Windows (With console window for debugging):

dotnet publish -c Release -r win-x64 --self-contained true -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true -p:OutputType=Exe

For Linux:

dotnet publish -c Release -r linux-x64 --self-contained true -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true

📖 How to Use

  1. Launch the App: Open the compiled executable.
  2. Load Template: Select your base image (PNG/JPG) using the UI.
  3. Map Fields: Draw bounding boxes where you want your CSV data to appear. Configure font sizes, colors, and alignments.
  4. Load Data: Select your .csv file containing the dynamic content.
  5. Generate: Hit "Run". The app will instantly process the batch, dynamically scale text to fit the boxes, and output highly compressed .avif files to your chosen directory.

⚡ Performance Architecture

To achieve high throughput without choking the system, the generator utilizes a hybrid threading approach:

  • Concurrent Image Processing: Reads and renders images in RAM asynchronously using Parallel.ForEachAsync (limited to 1/4 of total logical cores).
  • Dedicated Encoder Threads: Allocates the remaining CPU cores directly to the avifenc threads (-j parameter) for maximum SVT-AV1 encoding efficiency.
  • Zero-Leak Policy: SkiaSharp renders to a temporary OS file buffer, which is immediately garbage-collected and cleaned up post-encoding via strict finally blocks.

About

C# AvifGenerator

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages