👉 Try the demo: https://github.com/LM-Kit/lm-kit-net-samples/tree/main/console_net/document-intelligence/image-processing/image_normalizer_batch
Image Preprocessing for C# .NET Applications
🎯 Purpose of the Demo
An interactive console app that resizes, rotates, and auto-crops images for vision / OCR pipelines. Pick a single image or a whole folder, then opt in to each operation: thumbnail long-side, rotation (90 / 180 / 270), or auto-crop of uniform borders.
All processing runs on-device.
👥 Industry Target Audience
- Document capture: normalize phone uploads before OCR.
- e-commerce / DAM: produce consistent thumbnails for grid views.
- Vision pipelines: keep input dimensions within model budgets.
- Compliance: trim metadata-leaking borders before sharing.
- Archives: bulk-normalize legacy scans into a canonical size and orientation.
🚀 Problem Solved
Every VLM, OCR engine, and image-embedding model has an input budget. Sending a 12-megapixel phone photo straight to the model bloats tokens and hurts accuracy. The demo wraps the three most-used ImageBuffer transforms behind a menu, so the same prompt-driven flow handles one image or a folder of thousands.
💻 Application Overview
Interactive menu (no command-line arguments) with two modes:
| Mode | What it does |
|---|---|
| File | Process a single image with chosen options. Prompts for thumbnail long-side, rotation, and auto-crop. |
| Folder | Process every supported image in a folder (optionally recursive). Same option prompts. |
| Quit | Exit. |
Outputs are written as <basename>_thumb.png, <basename>_rot{deg}.png, <basename>_crop.png in the chosen output directory.
✨ Key Features
ImageBuffer.LoadAsRGB(path)andSaveAsPng(path).ImageBuffer.Resize(width, height): preserves aspect ratio when called via long-side prompt.ImageBuffer.Rotate(int degrees): 90, 180, or 270.ImageBuffer.CropAuto(margin): trims uniform borders.- Folder mode: per-file error handling, summary at the end.
🧠 Model
- None. Pure image transforms; no LLM is loaded.
🛠️ Getting Started
📋 Prerequisites
- .NET 8.0 or later
▶️ Running the Application
git clone https://github.com/LM-Kit/lm-kit-net-samples
cd lm-kit-net-samples/console_net/document-intelligence/image-processing/image_normalizer_batch
dotnet run
Pick a mode from the menu and follow the prompts.