---
Product: imaging
Platform: python
Page Type: index
Canonical URL: https://blog.aspose.org/imaging/python/introducing-imaging-foss-python/
Published: 2026-12-02
Author: Aspose
---

# Introducing Aspose.Imaging FOSS for Python

Aspose.Imaging FOSS for Python is a free, MIT-licensed library with no third-party dependencies that detects an image file's format and reads its header metadata — dimensions, bit depth, and frame count — without decoding a single pixel. It covers 14 formats, including asynchronous probing for asyncio applications.

## Introduction

Aspose.Imaging FOSS for Python is a free, MIT-licensed, open-source library for Python
developers who need to know what an image file *is* — its format, dimensions, bit depth, and
frame count — without paying the cost of decoding it. `detect_format()` reads an image's
signature and returns an `ImageFormat` enum value; `probe()` reads further into the header when
needed and returns an `ImageInfo` object with nullable `width`, `height`, `bit_depth`, and
`frame_count` properties, populated only when the detected format's header actually carries that
value. Both functions accept a file path, a byte buffer, or a binary stream.

This is a deliberately narrow tool, and that's the point. It does not decode pixels, render
images, or convert between formats — for that, the commercial Aspose.Imaging for Python product
is the right choice (linked below under Open Source & Licensing). What Aspose.Imaging FOSS for
Python does is the much smaller, much more common job of answering "what format is this, and how
big is it?" as fast and as safely as possible, for the class of problem where full decoding would
be wasted work: validating an upload, sizing a thumbnail layout, triaging a batch of mixed files,
or probing images inside an asyncio service without blocking the event loop.

The library is MIT-licensed, runs on Python 3.10 or later, and depends on nothing beyond the
standard library — free for both open-source and commercial use, with no royalties, provided the
copyright notice and license text are retained in copies.

---

## Key Features

### Two Functions, Three Kinds of Input

`detect_format()` and `probe()` both accept a file path, a byte buffer, or a binary stream —
seekable streams are read from the start, non-seekable streams from the current position.
`detect_format()` reads only up to the first 132 bytes and returns just the `ImageFormat` enum
value; `probe()` reads further when a format's metadata lives beyond the signature.

```python
from aspose_imaging_foss import ImageFormat, detect_format, probe

assert detect_format(b"GIF89a") == ImageFormat.GIF
info = probe("drawing.emf")
print(info.width, info.height, info.frame_count)
```

### Structured, Honest Results

`ImageInfo` exposes `format` (an `ImageFormat` enum value, always set once the header is
recognized) alongside nullable `width`, `height`, `bit_depth`, and `frame_count`. "Nullable" is
doing real work here: field population genuinely varies by format, and `ImageInfo` never
fabricates a value a format's header doesn't carry.

```python
info = probe("scan.dcm")
if info.width is not None and info.height is not None:
    print(f"{info.format}: {info.width}x{info.height}")
```

### 14 Formats, Including Several With No Other Free Python Detector

PNG/APNG, JPEG, BMP, PSD, GIF, WebP, ICO, TIFF, EMF, WMF, DICOM, DjVu, AVIF, and HEIC. Field
population differs by format on purpose, not by omission — PNG carries width, height, and bit
depth, and APNG's frame count comes from the `acTL` chunk before the first `IDAT` chunk; GIF and
WebP carry canvas dimensions and frame count but no bit depth; ICO reports the dimensions and bit
depth of the first image plus the number of images in the icon directory; TIFF reports the first
page's dimensions, bit depth per channel, and the number of pages in the IFD chain.

PSD, EMF/WMF, DICOM, DjVu, AVIF, and HEIC have no other free Python detector that we're aware of,
which is a real part of why this library exists.

A separate FOSS library, [Aspose.PSD FOSS for Python](https://products.aspose.org/psd/python/),
covers PSD layer metadata specifically, beyond header-only format detection.

### Asynchronous Probing, With Cancellation

`probe_async()` mirrors `probe()` for asyncio applications. It accepts the same path, buffer, or
stream inputs, plus streams with an asynchronous `read(size)` method such as
`asyncio.StreamReader`. Cancelling the asyncio task interrupts an in-progress asynchronous read;
regular file operations run in a worker thread instead.

```python
import asyncio
from aspose_imaging_foss import probe_async

async def main():
    info = await probe_async("drawing.emf")
    print(info.width, info.height)

asyncio.run(main())
```

### Never Raises on Truncated Input

`probe()` and `probe_async()` are built for untrusted, partial, or in-flight files. If a file
matches a format's signature but its header can't be fully parsed — a truncated download, a
corrupted upload — the result carries just the detected format rather than raising an exception.

```python
truncated = full_file_bytes[:-3]
info = probe(truncated)
# info.format is still populated; other fields may be None
```

---

## Quick Start

Install the package, then probe a file from disk to read its detected format, dimensions, bit
depth, and frame count in a single call, followed by a format-only check using the raw bytes:

```bash
git clone https://github.com/aspose-imaging-foss/Aspose.Imaging-FOSS-for-Python.git
cd Aspose.Imaging-FOSS-for-Python
pip install -e .
```

```python
from aspose_imaging_foss import ImageFormat, detect_format, probe

info = probe("photo.jpg")
print(f"{info.format}: {info.width}x{info.height}, {info.bit_depth}-bit, "
      f"{info.frame_count or 0} frame(s)")

# Format-only detection when dimensions aren't needed
with open("photo.jpg", "rb") as f:
    header = f.read(132)
format_only = detect_format(header)
```

---

## Supported Formats

Aspose.Imaging FOSS for Python **detects** all 14 formats below and reads header-level
metadata — it does not decode pixel data, so there is no "write" capability to report. Field
population varies by format; see the detailed breakdown in Key Features above.

| Format | Extension | Detected | Width / Height | Bit depth | Frame count |
|---|---|:---:|:---:|:---:|:---:|
| PNG / APNG | .png | ✓ | ✓ | ✓ | ✓ (APNG) |
| JPEG | .jpg / .jpeg | ✓ | ✓ | ✓ | — |
| BMP | .bmp | ✓ | ✓ | ✓ | — |
| PSD | .psd | ✓ | ✓ | ✓ | — |
| GIF | .gif | ✓ | ✓ | — | ✓ |
| WebP | .webp | ✓ | ✓ | — | ✓ |
| ICO | .ico | ✓ | ✓ (first image) | ✓ (first image) | ✓ (image count) |
| TIFF | .tif / .tiff | ✓ | ✓ (first page) | ✓ (per channel) | ✓ (page count) |
| EMF | .emf | ✓ | ✓ (from bounds) | — | — |
| WMF | .wmf | ✓ | ✓ (placeable only, 96 DPI) | — | — |
| DICOM | .dcm | ✓ | ✓ (Rows/Columns) | ✓ (BitsAllocated) | — |
| DjVu | .djvu | ✓ | ✓ (page dimensions) | — | ✓ (embedded pages) |
| AVIF | .avif | ✓ | ✓ (primary image) | — | — |
| HEIC | .heic | ✓ | ✓ (primary image) | — | — |

---

## Open Source & Licensing

Aspose.Imaging FOSS for Python is MIT-licensed and depends on nothing beyond the Python standard
library. MIT licensing permits use in both open-source and commercial projects with no royalties,
provided the copyright notice and license text are retained in copies. The source is available on
[GitHub](https://github.com/aspose-imaging-foss/Aspose.Imaging-FOSS-for-Python). It is
intentionally scoped to format detection only — for decoding, editing, or converting these image
formats, see [Aspose.Imaging for Python — Enterprise Product](https://products.aspose.com/imaging/python/).

---

## Getting Started

- [Getting Started](https://docs.aspose.org/imaging/python/getting-started/)
- [Developer Guide](https://docs.aspose.org/imaging/python/developer-guide/)
- [KB Articles](https://kb.aspose.org/imaging/python/)
- [API Reference](https://reference.aspose.org/imaging/python/)
- [Product Page](https://products.aspose.org/imaging/python/)

## Related Resources

- [Aspose.Imaging — Enterprise Blog](https://blog.aspose.com/)