Aspose.Imaging FOSS for .NET identifies an image file’s format and reads its basic header properties — dimensions, bit depth, and frame count — directly from the file header, without decoding a single pixel. The static ImageProbe class is the entry point: ProbeFile(path) reads from disk, Probe(stream) and Probe(data) accept a stream or byte array, and DetectFormat(stream) / DetectFormat(data) return just the ImageFormat enum value when dimensions aren’t needed. Every probe method returns an ImageInfo object with nullable Width, Height, BitDepth, and FrameCount properties, populated only when the detected format actually carries that value.
The library detects 11 formats — PNG, JPEG, GIF, BMP, WebP (lossy, lossless, and extended), ICO, TIFF, PSD, EMF, WMF, and DICOM — covering formats with no other FOSS .NET detector, such as PSD, EMF/WMF, and DICOM, with Implicit VR Little Endian and Explicit VR Little/Big Endian transfer syntax coverage. Probe never throws on malformed or truncated input: if a file matches a format’s signature but its header can’t be fully parsed, the result carries just the detected Format rather than an exception.
Aspose.Imaging FOSS for .NET is MIT-licensed with zero NuGet dependencies and targets both netstandard2.0 and net8.0. It is intentionally scoped to format detection only — for decoding, editing, or converting these image formats, see Aspose.Imaging for .NET — Enterprise Product.
ImageProbe.ProbeFile(path) reads a file from disk and returns an ImageInfo.ImageProbe.Probe(stream) and ImageProbe.Probe(data) accept a seekable or non-seekable stream, or a raw byte array.ImageProbe.DetectFormat(stream) and ImageProbe.DetectFormat(data) return just the ImageFormat enum value without building a full ImageInfo.ImageInfo exposes Format, plus nullable Width, Height, BitDepth, and FrameCount — populated only when the format actually carries that data.Width/Height from a file header to lay out a UI without loading the full image.Rows/Columns/BitsAllocated from a file header for fast pre-processing checks.Field population varies by format — every format is detected, but only some carry bit depth or frame count in their header. See the field support table below for the exact breakdown.
Probe returns an ImageInfo with just Format set, rather than an exception, when a file matches a format signature but its header can’t be fully parsed.FrameCount for animated GIFs, ICO, and TIFF, and branch downstream logic on the result.Install the package, then probe a file from disk.
git clone https://github.com/aspose-imaging-foss/Aspose.Imaging-Foss-for-.NET.git
cd Aspose.Imaging-Foss-for-.NET
dotnet buildusing Aspose.Imaging.Foss;
var info = ImageProbe.ProbeFile("photo.jpg");
Console.WriteLine($"{info.Format}: {info.Width}x{info.Height}, {info.BitDepth}-bit");
DetectFormat and Probe accept a seekable or non-seekable stream, or a raw byte array.
using Aspose.Imaging.Foss;
var format = ImageProbe.DetectFormat(bytes);
var info2 = ImageProbe.Probe(stream);
| Format | Width / Height | Bit depth | Frame count |
|---|---|---|---|
| PNG | ✓ | ✓ | ✓ |
| JPEG | ✓ | ✓ | — |
| GIF | ✓ | — | ✓ |
| BMP | ✓ | ✓ | — |
| WebP | ✓ | — | — |
| ICO | ✓ | ✓ | ✓ |
| TIFF | ✓ | ✓ | ✓ |
| PSD | ✓ | ✓ | — |
| EMF | ✓ (from bounds) | — | — |
| WMF (placeable) | ✓ (assumes 96 DPI) | — | — |
| DICOM | ✓ (Rows/Columns) | ✓ (BitsAllocated) | — |