docs: 同步需求、架构、模块清单、竞品分析与多语言 README
大石头 authored at 2026-11-28 21:46:17 大石头 committed at 2026-11-28 21:48:03
21.19 KiB
NewLife.Imaging
<!-- generated from README.md by sync-readme-package.ps1; do not edit --> # NewLife.Imaging - Pure Managed Imaging Library ![GitHub top language](https://img.shields.io/github/languages/top/newlifex/NewLife.Imaging?logo=github) ![GitHub License](https://img.shields.io/github/license/NewLifeX/NewLife.Imaging?logo=github) ![NuGet Downloads](https://img.shields.io/nuget/dt/NewLife.Imaging?logo=nuget) ![NuGet](https://img.shields.io/nuget/v/NewLife.Imaging?logo=nuget) ![NuGet prerelease](https://img.shields.io/nuget/vpre/NewLife.Imaging?label=dev%20nuget&logo=nuget) [![test](https://github.com/NewLifeX/NewLife.Imaging/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/NewLifeX/NewLife.Imaging/actions/workflows/test.yml) ![locales](https://img.shields.io/badge/locales-11-2ea44f?logo=dotnet) ![platform](https://img.shields.io/badge/platform-Windows%20%7C%20Linux%20%7C%20macOS%20%7C%20Android%20%7C%20iOS-blue) ![arch](https://img.shields.io/badge/arch-AnyCPU-orange) [![contributors](https://img.shields.io/github/contributors/NewLifeX/NewLife.Imaging?logo=github)](https://github.com/NewLifeX/NewLife.Imaging/graphs/contributors) <!-- lang:start --> 🌐 [简体中文](https://github.com/NewLifeX/NewLife.Imaging/blob/master/README.zh-CN.md) | [繁體中文](https://github.com/NewLifeX/NewLife.Imaging/blob/master/README.zh-TW.md) | [Español](https://github.com/NewLifeX/NewLife.Imaging/blob/master/README.es.md) | [Deutsch](https://github.com/NewLifeX/NewLife.Imaging/blob/master/README.de.md) | [日本語](https://github.com/NewLifeX/NewLife.Imaging/blob/master/README.ja.md) | [Français](https://github.com/NewLifeX/NewLife.Imaging/blob/master/README.fr.md) | [Português](https://github.com/NewLifeX/NewLife.Imaging/blob/master/README.pt.md) | [Русский](https://github.com/NewLifeX/NewLife.Imaging/blob/master/README.ru.md) | [한국어](https://github.com/NewLifeX/NewLife.Imaging/blob/master/README.ko.md) | [العربية](https://github.com/NewLifeX/NewLife.Imaging/blob/master/README.ar.md) <!-- lang:end --> > English | **[简体中文](https://github.com/NewLifeX/NewLife.Imaging/blob/master/README.zh-CN.md)** A pure managed .NET imaging foundation library: JPEG, PNG, GIF, BMP, ICO, QOI and PNM codecs, pixel processing, drawing primitives and metadata, with zero native dependencies by default. Source: https://github.com/NewLifeX/NewLife.Imaging NuGet: `NewLife.Imaging` ## Quick Start ```bash dotnet add package NewLife.Imaging ``` ```csharp using NewLife.Imaging; var frame = ImageFrame.Create(640, 480, PixelFormat.Rgb24); var row = frame.GetRowSpan(0); row[0] = 255; Console.WriteLine(ImageInfo.From(frame)); // Decode a JPEG, PNG, GIF, BMP, ICO, QOI or PNM file var photo = NewLife.Imaging.Codecs.ImageCodecs.Decode(File.ReadAllBytes("photo.jpg")); // Generate a captcha for a login page var captcha = NewLife.Imaging.Drawing.CaptchaGenerator.Generate(); File.WriteAllBytes("captcha.png", captcha.ToPng()); ``` Targets `net45`, `netstandard2.0`, `netstandard2.1`, `net8.0` and `net10.0`. ## Features The library ships the pixel model, the codec contract, pixel processing, drawing primitives and pure managed codecs. JPEG, PNG, GIF, BMP, ICO, QOI, PNM and TIFF (baseline, Deflate/LZW/PackBits, 8/16/32-bit float, CMYK) encode and decode in the main package; WebP supports VP8L lossless encode/decode, VP8 lossy key-frame decoding with alpha, and VP8/VP8L animation; JPEG supports CMYK encode/decode. Metadata covers raw EXIF/XMP/IPTC/ICC blocks plus EXIF/IPTC/XMP common-tag models, orientation, DPI, PNG text chunks and JPEG comments. <details> <summary><b>Image Codecs</b></summary> | Capability | What it gives you | | --- | --- | | Image frame model | One flat buffer, one pixel format and one stride convention shared by every NewLife library | | Pixel formats | 8-bit Gray/RGB/BGR/RGBA/BGRA, 16-bit Gray/RGB/RGBA, float Gray/RGB/RGBA and CMYK32 | | Codec contract | `IImageDecoder` / `IImageEncoder` with `ImageCodecCapabilities`, plus a thread-safe `ImageCodecs` registry | | JPEG, PNG, GIF, BMP, ICO, QOI, PNM, TIFF | Pure managed encoding and decoding; JPEG CMYK, TIFF 8/16/32-bit float and Deflate/LZW/PackBits; GIF/ICO/TIFF/APNG support multiple frames | | WebP | Pure managed VP8L lossless encoding, full VP8L decoding, VP8 lossy key-frame decoding with alpha, and VP8/VP8L animation | | Format sniffing | Magic-byte detection through `FindByData` for all decodable formats | </details> <details> <summary><b>Image Processing</b></summary> Implemented today: pixel format conversion, resize with nearest-neighbor and bilinear sampling, crop, right-angle rotation, flip, grayscale, Otsu binarization and brightness/contrast adjustment. The remaining rows are planned. | Capability | What it gives you | | --- | --- | | Pixel format conversion | Move between RGB, BGR, RGBA, BGRA and grayscale without leaving the model | | Resize and crop | Nearest, bilinear, bicubic and area averaging; rectangle crop and canvas expansion | | Rotate and flip | Lossless right-angle paths plus arbitrary-angle rotation | | Color adjustment | Brightness, contrast, saturation and gamma on a per-channel basis | | Grayscale and threshold | Weighted grayscale, fixed threshold and Otsu binarization | | Convolution | Mean and Gaussian blur, sharpen and Sobel edge detection | | Alpha compositing | Premultiply, unpremultiply and common Porter-Duff modes | | Histogram and quantization | Auto levels, equalization, palette quantization and dithering | </details> <details> <summary><b>Drawing Primitives</b></summary> Implemented today: canvas clearing and filling, Bresenham lines, rectangles, 8x8 bitmap text, image blitting and captcha generation. The remaining rows are planned. | Capability | What it gives you | | --- | --- | | Basic shapes | Lines, rectangles, circles, ellipses and polygons drawn directly on a frame | | Anti-aliasing | Coverage-based blending for lines and polygon edges | | Bitmap text | Built-in 8x16 ASCII font with scaling and foreground/background colors | | Image composition | Blit, scaled draw, alpha blend and opaque overwrite | | Captcha images | Random code with noise lines and dots, ready for admin login pages | | Clipping and masks | Rectangle clip regions and single-channel masks | | Gradients | Linear and radial gradients with multiple color stops | </details> <details> <summary><b>Metadata</b></summary> | Capability | What it gives you | | --- | --- | | EXIF | Read and write common camera, time, exposure and GPS tags; raw blocks for other tags | | ICC profiles | Read profile descriptions and embed raw profile data on encode | | DPI and physical size | Horizontal and vertical resolution with units | | Orientation | Read EXIF orientation and rotate pixels automatically | | Animation timing | Frame delays, loop counts and disposal methods for GIF and WebP | | Text chunks | PNG tEXt/zTXt/iTXt and JPEG COM markers | </details> <details> <summary><b>Adapters</b></summary> | Capability | What it gives you | | --- | --- | | System.Drawing | `Bitmap` to `ImageFrame` bridge for Windows-only legacy code | | WPF, WinUI, Avalonia | UI bitmap bridges in separate packages | | SkiaSharp | `SKBitmap` and `SKImage` bridges for existing Skia stacks | | Built-in codecs | JPEG, PNG, GIF, BMP, ICO, QOI and PNM are in the main package; no third-party codec dependency | | VideoFrame | Video frame adapters implemented in the NewLife.Video repository | | Office, Cube, Vision | Shared pixel model for documents, admin sites and vision pipelines | </details> ## Ecosystem Map NewLife is a layered ecosystem of independently versioned open-source projects. The map below is shared verbatim by every NewLife repository; each project links to its repository and its primary NuGet package. | Project | What it does | Downloads | | --- | --- | --- | | **Foundation** | | | | [NewLife.Core](https://github.com/NewLifeX/X) | Logging, configuration, caching, networking, serialization, scheduling and APM tracing. | [![NuGet](https://img.shields.io/nuget/dt/NewLife.Core?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.Core) | | [NewLife.XCode](https://github.com/NewLifeX/NewLife.XCode) | Data middleware: single tables at the tens-of-billions scale, automatic sharding, read-write splitting, 10+ databases. | [![NuGet](https://img.shields.io/nuget/dt/NewLife.XCode?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.XCode) | | [NewLife.Net](https://github.com/NewLifeX/NewLife.Net) | High-performance network library: 1.77M pps / 14.5 Gbps on a single machine (TCP 1KB, 2026-10), 4M long-lived TCP connections. | [![NuGet](https://img.shields.io/nuget/dt/NewLife.Net?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.Net) | | [NewLife.Remoting](https://github.com/NewLifeX/NewLife.Remoting) | Protocol communication and RPC framework for client/server applications and IoT devices. | [![NuGet](https://img.shields.io/nuget/dt/NewLife.Remoting?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.Remoting) | | [NewLife.Agent](https://github.com/NewLifeX/NewLife.Agent) | Installs .NET applications as OS daemons: Windows services and Linux systemd. | [![NuGet](https://img.shields.io/nuget/dt/NewLife.Agent?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.Agent) | | [NewLife.Templates](https://github.com/NewLifeX/NewLife.Zero) | `dotnet new` project templates for console, web, API, service, data and IoT projects. | [![NuGet](https://img.shields.io/nuget/dt/NewLife.Templates?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.Templates) | | **Data & Messaging** | | | | [NewLife.Redis](https://github.com/NewLifeX/NewLife.Redis) | Redis client with microsecond latency, millions of ops/s and built-in message queues. | [![NuGet](https://img.shields.io/nuget/dt/NewLife.Redis?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.Redis) | | [NewLife.RocketMQ](https://github.com/NewLifeX/NewLife.RocketMQ) | Pure managed RocketMQ client for Apache RocketMQ and Alibaba Cloud Message Queue. | [![NuGet](https://img.shields.io/nuget/dt/NewLife.RocketMQ?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.RocketMQ) | | [NewLife.MQTT](https://github.com/NewLifeX/NewLife.MQTT) | MQTT client and server, including Alibaba Cloud IoT connectivity. | [![NuGet](https://img.shields.io/nuget/dt/NewLife.MQTT?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.MQTT) | | [NewLife.NovaDb](https://github.com/NewLifeX/NewLife.NovaDb) | Hybrid database in C#: embedded or networked, relational, time-series, message queue and KV in one. | [![NuGet](https://img.shields.io/nuget/dt/NewLife.NovaDb?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.NovaDb) | | [NewLife.MySql](https://github.com/NewLifeX/NewLife.MySql) | MySql driver and helper layer built on the NewLife data stack. | [![NuGet](https://img.shields.io/nuget/dt/NewLife.MySql?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.MySql) | | [NewLife.TDengine](https://github.com/NewLifeX/NewLife.TDengine) | Pure managed TDengine ADO.NET driver with REST, WebSocket and native RPC transports, no native dependency. | [![NuGet](https://img.shields.io/nuget/dt/NewLife.TDengine?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.TDengine) | | [NewLife.Presto](https://github.com/NewLifeX/NewLife.Presto) | Pure C# Presto/Trino ADO.NET driver with zero third-party dependencies and XCode ORM integration. | [![NuGet](https://img.shields.io/nuget/dt/NewLife.Presto?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.Presto) | | **Web & Distributed** | | | | [NewLife.Cube](https://github.com/NewLifeX/NewLife.Cube) | Rapid admin-platform framework: permissions, SSO, OAuth server and CRUD scaffolding. | [![NuGet](https://img.shields.io/nuget/dt/NewLife.Cube?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.Cube) | | [NewLife.Cube.React](https://github.com/NewLifeX/NewLife.Cube.React) | Decoupled front-end sample for Cube: WebAPI backend with Swagger plus React, Vue and Blazor clients. | [![NuGet](https://img.shields.io/nuget/dt/NewLife.Cube.React?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.Cube.React) | | [Stardust](https://github.com/NewLifeX/Stardust) | Distributed service platform: node management, APM, configuration center, registry and release center. | [![NuGet](https://img.shields.io/nuget/dt/NewLife.Stardust?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.Stardust) | | [AntJob](https://github.com/NewLifeX/AntJob) | Distributed task and real-time data scheduling platform with sharding, retries and backfill. | [![NuGet](https://img.shields.io/nuget/dt/NewLife.AntJob?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.AntJob) | | **AI & Vision** | | | | [NewLife.AI](https://github.com/NewLifeX/NewLife.AI) | Unified client for 46 LLM providers plus ChatAI, a ready-to-run web chat application. | [![NuGet](https://img.shields.io/nuget/dt/NewLife.AI?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.AI) | | [NewLife.Imaging](https://github.com/NewLifeX/NewLife.Imaging) | Pure managed imaging foundation: pixel model, codec contracts, drawing and metadata with zero native dependencies. | — | | [NewLife.Vision](https://github.com/NewLifeX/NewLife.Vision) | Vision algorithms: OCR, barcodes, object detection and face recognition on top of NewLife.Imaging. | — | | [NewLife.ML](https://github.com/NewLifeX/NewLife.ML) | Tabular machine learning for .NET: turn database tables and Excel sheets into deployable prediction and classification models. | — | | **Industrial & IoT** | | | | [NewLife.IoT](https://github.com/NewLifeX/NewLife.IoT) | IoT standard library defining protocol contracts and device abstractions. | [![NuGet](https://img.shields.io/nuget/dt/NewLife.IoT?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.IoT) | | [NewLife.Modbus](https://github.com/NewLifeX/NewLife.Modbus) | Modbus TCP/RTU/ASCII implementation on top of NewLife.IoT. | [![NuGet](https://img.shields.io/nuget/dt/NewLife.Modbus?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.Modbus) | | [NewLife.Siemens](https://github.com/NewLifeX/NewLife.Siemens) | Siemens PLC protocol on top of NewLife.IoT. | [![NuGet](https://img.shields.io/nuget/dt/NewLife.Siemens?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.Siemens) | | [NewLife.Omron](https://github.com/NewLifeX/NewLife.Omron) | Omron PLC protocol on top of NewLife.IoT. | [![NuGet](https://img.shields.io/nuget/dt/NewLife.Omron?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.Omron) | | [NewLife.Melsec](https://github.com/NewLifeX/NewLife.Melsec) | Mitsubishi Melsec PLC protocol on top of NewLife.IoT. | [![NuGet](https://img.shields.io/nuget/dt/NewLife.Melsec?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.Melsec) | | [NewLife.Schneider](https://github.com/NewLifeX/NewLife.Schneider) | Schneider PLC communication driver built on Modbus TCP. | [![NuGet](https://img.shields.io/nuget/dt/NewLife.Schneider?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.Schneider) | | [NewLife.OPC](https://github.com/NewLifeX/NewLife.OPC) | OPC client for industrial data access. | — | | [NewLife.BACnet](https://github.com/NewLifeX/NewLife.BACnet) | BACnet building-automation protocol stack. | [![NuGet](https://img.shields.io/nuget/dt/NewLife.BACnet?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.BACnet) | | [NewLife.LoRa](https://github.com/NewLifeX/NewLife.LoRa) | LoRaWAN low-power wide-area protocol for long-range IoT connectivity. | [![NuGet](https://img.shields.io/nuget/dt/NewLife.LoRa?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.LoRa) | | [ZeroIoT](https://github.com/NewLifeX/ZeroIoT) | Lightweight open-source IoT platform with gateway and device management. | — | | **Vehicle Telematics** | | | | [NewLife.JT808](https://github.com/NewLifeX/NewLife.JT808) | JT/T 808 vehicle positioning protocol: 70+ message bodies, 2011/2013/2019. | [![NuGet](https://img.shields.io/nuget/dt/NewLife.JT808?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.JT808) | | [NewLife.JT809](https://github.com/NewLifeX/NewLife.JT809) | JT/T 809 platform-to-platform protocol for transport authorities. | [![NuGet](https://img.shields.io/nuget/dt/NewLife.JT809?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.JT809) | | [NewLife.JT1078](https://github.com/NewLifeX/NewLife.JT1078) | JT/T 1078 in-vehicle video: RTP parsing, FLV/fMP4 remuxing and live streaming. | [![NuGet](https://img.shields.io/nuget/dt/NewLife.JT1078?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.JT1078) | | **Domain Components** | | | | [NewLife.Office](https://github.com/NewLifeX/NewLife.Office) | One package for Excel, Word, PPT, PDF and 15+ document formats. | [![NuGet](https://img.shields.io/nuget/dt/NewLife.Office?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.Office) | | [NewLife.Audio](https://github.com/NewLifeX/NewLife.Audio) | Cross-platform audio: codecs, device I/O, DSP, containers and streaming. | [![NuGet](https://img.shields.io/nuget/dt/NewLife.Audio?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.Audio) | | [NewLife.Video](https://github.com/NewLifeX/NewLife.Video) | Video codecs, container formats, frame processing and streaming. | [![NuGet](https://img.shields.io/nuget/dt/NewLife.Video?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.Video) | | [NewLife.Map](https://github.com/NewLifeX/NewLife.Map) | Unified interface over Baidu, AMap, Tencent and Tianditu with geocoding and coordinate conversion. | [![NuGet](https://img.shields.io/nuget/dt/NewLife.Map?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.Map) | | [NewLife.IP](https://github.com/NewLifeX/NewLife.IP) | IPv4 geolocation with an offline memory-mapped database and an online API fallback. | [![NuGet](https://img.shields.io/nuget/dt/NewLife.IP?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.IP) | | [NewLife.Holiday](https://github.com/NewLifeX/NewLife.Holiday) | Chinese holiday and adjusted-workday identification library with built-in annual data and lunar festival support, fully offline. | [![NuGet](https://img.shields.io/nuget/dt/NewLife.Holiday?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.Holiday) | | **Tools & Products** | | | | [CrazyCoder](https://github.com/NewLifeX/XCoder) | Developer toolbox: network, serial port, crypto, regex, Modbus and MQTT. | [![NuGet](https://img.shields.io/nuget/dt/NewLife.XCoder?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.XCoder) | | [NewLife.UnitTest](https://github.com/NewLifeX/NewLife.UnitTest) | Unit test extensions: test base classes, data-driven tests and dependency-injection helpers. | [![NuGet](https://img.shields.io/nuget/dt/NewLife.UnitTest?style=flat-square&logo=nuget&label=downloads)](https://www.nuget.org/packages/NewLife.UnitTest) | | [GitCandy](https://github.com/NewLifeX/GitCandy) | Self-hosted Git source code management system. | — | | [LuckyClover](https://github.com/NewLifeX/LuckyClover) | Installs the matching .NET runtime automatically when launched from an older host. | — | > Badges show the primary package of each project; theme, extension and satellite packages are listed on their NuGet pages. The 30+ packages not listed here (FTP, Office extensions, protocol drivers and more) are available under the [NewLifeX organization](https://github.com/NewLifeX) and on [newlifex.com](https://newlifex.com). ## Documentation | Document | Description | | --- | --- | | [Requirements](https://github.com/NewLifeX/NewLife.Imaging/blob/master/Doc/需求文档.md) | Vision, core goals and module breakdown | | [Feature List](https://github.com/NewLifeX/NewLife.Imaging/blob/master/Doc/模块清单.md) | Implementation, test and documentation status | | [Architecture](https://github.com/NewLifeX/NewLife.Imaging/blob/master/Doc/架构设计.md) | Structure, boundaries and key design decisions | | [Competitive Analysis](https://github.com/NewLifeX/NewLife.Imaging/blob/master/Doc/竞品分析.md) | Comparison with ImageSharp, SkiaSharp, Magick.NET and others | | [Change Log](https://github.com/NewLifeX/NewLife.Imaging/blob/master/Doc/ChangeLog.md) | Release history | | [Samples](https://github.com/NewLifeX/NewLife.Imaging/blob/master/Samples/ImagingDemo) | Runnable console sample | ## Contributing Issues and pull requests are welcome. Please run the same checks as CI before submitting: ```bash dotnet build -c Release dotnet test -c Release pwsh -File Tools/Scripts/check-readmes.ps1 ``` ## License [MIT License](https://github.com/NewLifeX/NewLife.Imaging/blob/master/LICENSE)