Pure C# implementation + AOT-built multifunctional image processing tool ImageGlider
The ImageGlider, built with pure C# and AOT, has image processing features piled up like a mountain, yet it insists on touting zero dependencies? ImageSharp is wrapped quite smoothly, but it's uncertain how far this modular architecture can go. The Web API and CLI tools have some merit, but don't expect me to praise it excessively.
目录9 个章节
Preface
Last time, I developed an ICO Icon Generator using C# + AOT.
This practical little tool attracted a lot of attention from friends as soon as it was released.
Recently, it was even made into a website with a graphical interface for one-click generation of .ico icons, making it more convenient for regular users.
This kind of C# development with automated GitHub Actions publishing of NuGet packages and dotnet tools offers such a great one-stop experience that I became somewhat addicted to the feeling.
Recently, I've developed a couple of similar tools in succession, one of which is the image processing tool I will introduce in this article.
The project is open-source. Stars and PRs are welcome: https://github.com/star-plan/image-glider
About ImageGlider
Initially, I developed this tool simply to batch convert jfif images in a directory to jpg or png format that Windows File Explorer could display as thumbnails.
However, during the development process, I discovered how convenient it is to build small utilities with C#, so I gradually added a bunch of additional features.
Next, I also plan to add a similar image recognition function.
Here is the current project introduction:
ImageGlider is a powerful, cross-platform image processing toolkit, implemented in C# (.NET 9) using ImageSharp. The project uses a modular architectural design, including a core class library, command-line tool, Web API, sample programs, and comprehensive unit tests. It supports AOT compilation for native performance.
With ImageGlider, you can easily perform image processing operations, completely free from external dependencies. It does not require ImageMagick, Node.js, or Python, making it suitable for embedding within .NET projects, distribution, or integration into automated workflows.
The goal is to create a cross-platform, zero-dependency, high-performance, and fully-featured image processing solution! (It can be understood as a simplified version of ImageMagick)
Project Repository: https://github.com/star-plan/image-glider
Features
🎯 Core Image Processing Functions
- 🖼️ Format Conversion: Supports mutual conversion between various image formats such as JPEG, PNG, GIF, BMP, TIFF, WebP, etc.
- 📏 Resizing: Supports multiple adjustment modes including stretching, maintaining aspect ratio, and cropping
- 🗜️ Compression Optimization: Smart compression algorithms to reduce file size while maintaining quality
- ✂️ Image Cropping: Precise cropping of specified areas, supports center cropping and custom coordinate cropping
- 🖼️ Thumbnail Generation: Quickly generate high-quality thumbnails with support for multiple size modes
- 💧 Watermark Function: Supports text and image watermarks with 9 position choices, adjustable transparency and scaling
- 🧹 Metadata Cleaning: One-click removal of privacy-sensitive metadata information such as EXIF, ICC, XMP
- 🎨 Color Adjustment: Adjust color parameters including brightness, contrast, saturation, hue, gamma value, etc.
- ℹ️ Information Extraction: Obtain detailed image information with support for JSON format output
🛠️ Technical Features
- 🚀 Cross-platform: Based on .NET 9 and ImageSharp, supporting Windows, Linux, macOS
- ⚡ AOT Compilation: Supports native AOT compilation for fast startup and low memory usage
- 📦 Zero-dependency: No need to install additional image processing tools or runtime environments
- 🧩 Modular Design: Core functionalities encapsulated as independent class libraries for easy integration and extension
- 🔧 Multiple Interfaces: Provides three usage modes: CLI tool, Web API, and core class library
💻 Usage
- Command-line Tools: 16 professional commands, supporting single-file and batch processing
- Web API: RESTful interface, supporting HTTP file upload and processing
- Core Library: Directly integrate into .NET projects for use
- Batch Processing: Automatically scan directories, supporting recursive processing and file filtering
- Detailed Logging: Complete log recording, supporting multiple log levels
- Error Handling: Robust exception handling mechanism, providing detailed processing result information
Usage
Install as a .NET Global Tool (Recommended)
dotnet tool install --global ImageGlider.Cli
After installation, you can use it from the command line.
$ imageglider
=== ImageGlider Command Line Tool ===
Usage:
ImageGlider.Cli <command> [options]
ImageGlider.Cli help [command] Show help information
Available Commands:
adjust Adjust color properties of a single image file (brightness, contrast, saturation, hue, gamma)
batch-adjust Batch adjust color properties of image files in a specified directory (brightness, contrast, saturation, hue, gamma)
batch-compress Batch compress and optimize image files
batch-convert Batch convert image files
batch-crop Batch crop image files in a specified directory
batch-info Batch view detailed information of image files in a directory
batch-resize Batch resize image files
batch-strip-metadata Batch strip metadata from image files in a specified directory
batch-thumbnail Batch generate thumbnails for image files in a specified directory
batch-watermark Batch add watermarks to image files
compress Compress and optimize a single image file
convert Convert a single image file
crop Crop a single image file
info View detailed information of an image file
resize Resize a single image file
strip-metadata Strip metadata from a single image file
thumbnail Generate a thumbnail for a single image file
watermark Add a watermark to a single image file
Use 'ImageGlider.Cli help <command>' to view detailed help for a specific command.
Examples:
ImageGlider.Cli convert -s image.jfif -t image.jpeg -q 85
ImageGlider.Cli batch-convert -se .jfif -te .jpeg -q 90
ImageGlider.Cli resize -s input.jpg -t output.jpg -w 800 -h 600
ImageGlider.Cli compress -s input.jpg -t output.jpg -l 60
ImageGlider.Cli help convert
AOT and Other Methods
Installation via other methods (such as scoop, brew) and AOT compilation releases will not be detailed in this article. Please refer to the Project Documentation.
Summary
This development workflow is so pleasant that I even want to integrate it into my template project FluentConsole.
Next, I will publish several articles related to this workflow. If you are interested, feel free to follow along.
_EOF_
Pure C# implementation + AOT-built multifunctional image processing tool ImageGlider
- 本文作者:
- 程序设计实验室
- 版权声明:
- 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
相关文章
让 C# 也拥有 gofmt 般的体验:用 CSharpier + Roslyn 实现 csfmt
C# 代码长到像答辩?用 CSharpier 自动折行,再用 Roslyn 修正 K&R 花括号,Taskfile 一键收尾。再补上 format-check,省得 CI 反复制造 Git diff。两步流水线并非原生 gofmt,顺序和版本仍得老实锁住。
2026-10-22 · C# · 约 1 分钟
C#移除字符串中的不可见Unicode字符
背景 最近发现某个数据采集的系统拿下来的数据,有些字段的JSON被莫名截断了,导致后续数据分析的时候解析JSON失败。 类似这样 {title: 你好 或者这样,多了个双引号啥的 {title:你好} 因为数据库是Oracle,起初以为是Oracle这老古董出问题了,结果一番折腾,把每条写入数据的SQL语句都拿出来,看起来里面的JSON格式都没问题。 这也太诡异了吧,看起来没毛病,但就为啥JSON
2023-02-02 · C# · 约 1 分钟
C#学习(一)委托的概念和使用
前言 C#学习系列是根据我以前的笔记整理出来复习,顺便发一下文章做个记录。 先引用一个介绍: C# 中的委托(Delegate)类似于 C 或 C++ 中函数的指针。委托(Delegate) 是存有对某个方法的引用的一种引用类型变量。引用可在运行时被改变。 委托(Delegate)特别用于实现事件和回调方法。所有的委托(Delegate)都派生自 System.Delegate 类。 根据使用其他
2021-12-18 · C# · 约 1 分钟
C#使用iKvm黑科技无缝接入JVM生态
C#开发者用iKVM白嫖JVM生态?省事,但依赖处理还得手动折腾。无缝接入?不过是把JAR转DLL,省了移植代码的麻烦。AI工具缺?直接调用HanLP,但依赖处理,呵呵。
2023-10-06 · C# · 约 1 分钟
讨论
共 0 条加载评论中…