Skip to content

A cross-platform desktop application and web API for enhancing images using Real-ESRGAN AI models and converting them to modern, efficient formats like WebP and AVIF.

Notifications You must be signed in to change notification settings

specializeddevel/ia_image_enhancer_csharp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

48 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Image Enhancer AI (.NET Edition)

.NET 9 Avalonia UI ASP.NET Core Platforms License

GitHub Stars GitHub Forks GitHub Issues

A cross-platform desktop application and web API for enhancing images using Real-ESRGAN AI models and converting them to modern, efficient formats like WebP and AVIF.

Table of Contents

Features

  • Configuration Profiles: Save and load entire processing configurations for repeatable workflows.
  • Auto-Load Last Profile: The application automatically loads your last-used profile on startup.
  • AI-Powered Upscaling: Enhance image resolution by 4x using state-of-the-art Real-ESRGAN models.
  • Modern Format Conversion: Convert images to high-efficiency formats like .webp and .avif.
  • Batch Processing: Process entire folders of images, including subfolders, in one go.
  • Cross-Platform: Runs on Windows, macOS, and Linux.
  • Dual Interface: Use the simple and intuitive desktop GUI (built with Avalonia) or the headless Web API for programmatic access.
  • Detailed Progress Display: Track overall and per-folder progress with details on file counts and space savings.
  • UI/UX Enhancements:
    • Drag and Drop support for selecting folders.
    • Maximized window on startup for a better view.
    • Dark & Light themes.
    • Input validation and clear user feedback.
  • Processing Log: Keep track of all processed images.

Profile Management

The application now supports saving your settings into named profiles.

  • Saving a Profile: Configure your desired settings (folders, model, options) on the main window. Type a name in the text box next to the "Save as Profile" button and click it. The button will be disabled if the name is empty.
  • Loading and Deleting Profiles: Click the "Profiles..." button at the top right to open the Profile Manager. From there, you can select a profile to either load its settings or delete it permanently.

Solution Structure

The solution is divided into four projects:

  • ImageProcessor.Core: A .NET library project that contains the core logic for image processing. It orchestrates the command-line tools to perform image enhancement and conversion.
  • ImageProcessor.Api: An ASP.NET Core web API that exposes the image processing functionality as a web service.
  • ImageProcessor.UI: A desktop application built with Avalonia UI that provides a graphical user interface.
  • image-processor-web: A React-based web application that consumes the API.

How it Works

The application uses a pipeline of command-line tools to process images:

  1. Upscaling (Optional): If enabled, the source image is first passed to realesrgan-ncnn-vulkan to be upscaled.
  2. Conversion (Optional): The (potentially upscaled) image is then converted to either .webp using cwebp.exe or .avif using ffmpeg.exe.
  3. File Handling: The application manages the creation of output folders and the deletion of intermediate and source files.

The API uses a job-based system to handle processing requests asynchronously.

API Endpoints

The API provides endpoints for starting and monitoring processing jobs.

POST /api/Processing/start

Starts a new image processing job. The request body must be a JSON object with the processing options. The response will contain a jobId that can be used to track the status of the job.

Example JSON Body:

{
  "inputFolder": "C:\\path\\to\\your\\images",
  "outputFolder": "C:\\path\\to\\output",
  "model": "realesrgan-x4plus",
  "processSubfolders": true,
  "convertToWebP": true,
  "convertToAvif": false,
  "applyUpscale": true,
  "deleteSourceFile": false,
  "includeWebPFiles": false,
  "includeAvifFiles": false
}

GET /api/Processing/{jobId}/status

Gets the current status of a processing job.

GET /api/Processing/{jobId}/history

Gets the complete progress history of a processing job.

Screenshots

(Note: The screenshot below is outdated and will be updated soon to reflect the latest UI changes.)

IMAGE

Processing Options Explained

The main window provides several options to customize the image processing workflow.

Option Description
Use input folder as output folder If checked, the output files will be saved in the same folder as the input files. This disables the output folder selection.
AI Model Selects the Real-ESRGAN AI model to use for the upscaling process. Different models are trained for specific types of content.
Show Preview A ToggleSwitch to show or hide the image preview panel.
Apply 4x Upscale If checked, the AI-powered upscaling process is applied to the images. If unchecked, the application will only perform format conversion.
Convert to .WebP If checked, the final image will be converted to the .webp format.
Convert to .AVIF If checked, the final image will be converted to the .avif format using ffmpeg.
Process Subfolders If checked, the application will search for images in all subdirectories of the selected input folder.
Include .WebP Files If checked, existing .webp files in the source folder will be included in the processing queue.
Include .Avif Files If checked, existing .avif files in the source folder will be included in the processing queue.
Delete Source Files (Use with caution!) If checked, the original source image will be permanently deleted after it has been successfully processed.

πŸ’‘ Note
Conversion quality settings for WebP and AVIF can be found in the Settings window (click the βš™οΈ icon).

Settings

The settings window allows for more advanced configuration.

Setting Description
WebP Quality A slider (1-100) to control the quality of the WebP conversion. Higher values result in better quality and larger file sizes.
AVIF Quality A slider (1-100) to control the quality of the AVIF conversion. Higher values result in better quality and larger file sizes.
Real-ESRGAN Command Line Arguments Allows customization of the command-line arguments passed to the realesrgan-ncnn-vulkan executable for advanced users.

Prerequisites and Downloads

πŸ’‘ Note
For now, all Microsoft Windows prerequisites are included in the release package, available inside the compressed file: [https://github.com/specializeddevel/ia_image_enhancer_csharp/releases]

To build and run this project from source, you will need the .NET 9 SDK.

Required Files

For the application to function correctly, you need to either build from source and acquire the files listed below, or use a pre-compiled version.

Folder Structure Example (Windows)

This is an example of the required folder structure for running ImageProcessor.UI from the packaged release on Windows. The same structure applies to ImageProcessor.Api.

ImageProcessor.UI
└─ models/                         # realesrgan models
    └─ realesr-animevideov3-x2.bin
    └─ ...      
β”œβ”€ cwebp.exe                       # Compression Windows executable
β”œβ”€ ffmpeg.exe                      # Ffmpeg Windows executable
β”œβ”€ ImageProcessor.UI.exe           # Main ImageProcessor User Interface executable.
└─ realesrgan-ncnn-vulkan.exe      # AI model Windows executable

If you are running the project from source, make sure the required files follow this structure:

ia_image_enhancer_csharp/
└─ ImageProcessor.UI/          
   └─ bin/
      └─ Debug/
         └─ net9.0/
            └─ models/                     # realesrgan models
               └─ realesr-animevideov3-x2.bin
               └─ ...      
            β”œβ”€ cwebp.exe                   # Compression Windows executable
            β”œβ”€ ffmpeg.exe                  # Ffmpeg Windows executable
            β”œβ”€ ImageProcessor.UI.exe       # Main ImageProcessor User Interface executable.
            └─ realesrgan-ncnn-vulkan.exe  # AI model Windows executable

πŸ’‘ Note The /bin folder will be generated automatically after the first successful build.

1. External Binaries

This application relies on external command-line tools. These must be placed in the main application directory.

⚠️ Important
GPU Requirement: AI upscaling requires a graphics card that supports Vulkan 1.1 or higher.

πŸ’‘ Note
Linux/macOS Permissions: On Linux and macOS, you must grant execution permissions to the binaries.

chmod +x ./realesrgan-ncnn-vulkan
chmod +x ./cwebp
chmod +x ./ffmpeg

2. Models Folder

You must have a folder named models in the application's root directory. This folder must contain the .bin and .param files for the Real-ESRGAN models you intend to use.

Getting Started

  1. Clone the repository:

    git clone https://github.com/specializeddevel/ia_image_enhancer_csharp.git
    cd ia_image_enhancer_csharp
  2. Add Required Files: Follow the instructions in the Required Files section to download and place the necessary binaries and models.

  3. Build the project:

    dotnet build
  4. Run the application:

    • To run the Desktop UI:

      dotnet run --project ImageProcessor.UI
    • To run the Web API:

      dotnet run --project ImageProcessor.Api

Technologies Used

  • .NET 9 / C#: The core application logic and UI are built with the latest version of .NET.
  • Avalonia UI: A cross-platform UI framework for creating the desktop application.
  • ASP.NET Core: Used to create the Web API for headless processing.
  • MVVM Pattern: The Model-View-ViewModel pattern is used to structure the UI code, powered by the CommunityToolkit.Mvvm library.
  • Swagger / OpenAPI: Used for API documentation and testing in the ImageProcessor.Api project via the Swashbuckle.AspNetCore library.

Contributing

Contributions are welcome! If you have a feature request, bug report, or pull request, please feel free to open an issue or submit a PR.

We follow a feature-branch workflow with Pull Requests for merging changes into the main branch.

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

Disclaimer

This project uses external, pre-compiled binaries for image processing. These binaries are provided by their respective authors and are subject to their own licenses. Please ensure you comply with their terms of use.

About

A cross-platform desktop application and web API for enhancing images using Real-ESRGAN AI models and converting them to modern, efficient formats like WebP and AVIF.

Resources

Stars

Watchers

Forks

Packages

No packages published