---
Product: imaging
Platform: python
Page Type: docs
Canonical URL: https://docs.aspose.org/imaging/python/developer-guide/features
---

# Features and Functionalities

Complete feature reference for Aspose.Imaging FOSS for Python — detect_format, probe, probe_async, ImageInfo, per-format header quirks, and the 14-format detection matrix.

## Overview

This page covers every feature area of Aspose.Imaging FOSS for Python's format-detection
and header-probing API, with working Python examples. The library never decodes pixel data —
every function reads only the file header.

---

### Format Detection

`detect_format()` and `probe()` both accept a file path, a bytes buffer, or a binary
stream:

```python
from aspose_imaging_foss import detect_format, probe

from_path = probe("photo.jpg")
with open("photo.jpg", "rb") as f:
    from_bytes = detect_format(f.read())

format_only = detect_format(b"GIF89a")  # ImageFormat only, no full header parse
```

Use `detect_format()` when you only need to branch on the format; use `probe()` when
you also need dimensions, bit depth, or frame count. `detect_format()` reads only up
to the first 132 bytes of the input.

---

### Reading Header Metadata

`probe()` returns an `ImageInfo` with nullable `width`, `height`, `bit_depth`, and
`frame_count` — each populated only when the detected format's header actually
carries that value:

```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}")
```

`format` (an `ImageFormat` enum value) is always set once the header is recognized —
it's the one field guaranteed to be populated.

---

### Asynchronous Probing

`probe_async()` mirrors `probe()` for asyncio applications, accepting the same path,
buffer, or stream inputs, plus streams exposing an asynchronous `read(size)` method:

```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())
```

Cancelling the asyncio task interrupts an in-progress asynchronous read; regular file
operations run in a worker thread instead.

---

### Per-Format Notes

A few formats have header quirks `ImageInfo` normalizes or exposes directly:

| Format | Behavior |
|---|---|
| APNG | `frame_count` comes from the `acTL` chunk before the first `IDAT` chunk |
| GIF / WebP | Canvas dimensions and `frame_count` are populated; `bit_depth` is not |
| ICO | Dimensions and bit depth reflect the first embedded image; `frame_count` reflects the number of images in the icon directory |
| TIFF | Dimensions and bit depth reflect the first page; `frame_count` reflects the number of pages walked in the IFD chain |
| WMF | Dimensions populate only for placeable WMF, derived from the header's bounds at 96 DPI |
| EMF | Dimensions are derived from the header's bounds rectangle; there is no explicit width/height field |
| DICOM | Header parsing extracts Rows/Columns/BitsAllocated |

```python
# DICOM: Rows -> height, Columns -> width, BitsAllocated -> bit_depth
dicom_info = probe(dicom_bytes)
print(f"{dicom_info.width}x{dicom_info.height}, {dicom_info.bit_depth}-bit")
```

---

### Supported Formats

All 14 formats are detected the same way — `detect_format()`/`probe()` identify the
format and read header metadata; neither decodes or re-encodes pixel data for any of
them. Field population genuinely varies by format, though — every format sets
`format`, but only some carry bit depth or frame count in their header:

| Format | Width / Height | Bit depth | Frame count |
|---|:---:|:---:|:---:|
| PNG / APNG | ✓ | ✓ | ✓ (APNG) |
| JPEG | ✓ | ✓ | — |
| BMP | ✓ | ✓ | — |
| PSD | ✓ | ✓ | — |
| GIF | ✓ | — | ✓ |
| WebP | ✓ | — | ✓ |
| ICO | ✓ (first image) | ✓ (first image) | ✓ (image count) |
| TIFF | ✓ (first page) | ✓ (per channel) | ✓ (page count) |
| EMF | ✓ (from bounds) | — | — |
| WMF | ✓ (placeable only, 96 DPI) | — | — |
| DICOM | ✓ (Rows/Columns) | ✓ (BitsAllocated) | — |
| DjVu | ✓ (page dimensions) | — | ✓ (embedded pages) |
| AVIF | ✓ (primary image) | — | — |
| HEIC | ✓ (primary image) | — | — |

An unrecognized header resolves to `ImageFormat.UNKNOWN` rather than raising an
exception.

---

### Resilient by Design

`probe()` and `probe_async()` never raise on malformed or truncated input. Instead of
raising an exception, they return a partial `ImageInfo` — `format` is set whenever the
header's format marker was recognized, even when the rest of the file is cut short or
corrupt:

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

This makes both functions safe to run against untrusted, partial, or in-flight
downloads without wrapping every call in a try/except block.

---

### Tips and Best Practices

- Use `detect_format()` instead of `probe()` when you only need the format, not dimensions
- Check `width`/`height`/`bit_depth`/`frame_count` for `None` before using them — they are not populated for every format
- Use `probe_async()` inside asyncio services to avoid blocking the event loop on file or network I/O
- Both functions accept a file path, a bytes buffer, or a binary/async stream — pick whichever avoids an extra copy in your pipeline

---

### Common Issues

| Issue | Cause | Fix |
|---|---|---|
| `format` is `ImageFormat.UNKNOWN` | Header does not match any of the 14 recognized formats, or the signature appears beyond the first 132 bytes `detect_format()` reads | Confirm the file is one of the 14 supported formats and that a larger buffer is supplied if needed |
| `width`/`height` are `None` | The format's header doesn't carry that field, or the header was truncated before that field | Check `format` first; not every field is populated for every format |
| `probe_async()` call never resolves | Supplied stream's `read(size)` is not actually awaitable | Confirm the stream implements an asynchronous `read(size)` method such as `asyncio.StreamReader` |

---

### FAQ

#### Does probe() decode pixel data?

No. Every function reads only the file header — dimensions, bit depth, and frame
count — never pixel content. Decoding and rendering are outside this library's scope.

#### What happens if I probe a corrupted or truncated file?

`probe()` and `probe_async()` never raise for malformed or truncated input. They
return an `ImageInfo` with whatever fields they could determine from the available
header bytes — `format` is set whenever the format marker itself was recognized.

#### Can I probe a stream that isn't seekable?

Yes. Both `probe()` and `probe_async()` accept non-seekable streams, reading forward
from the current position.

#### Is there a synchronous and an asynchronous version of every function?

`detect_format()` and `probe()` are synchronous; `probe_async()` is the asynchronous
counterpart to `probe()` for asyncio applications.

---

### API Reference Summary

| Function / Type | Description |
|---|---|
| `detect_format(source)` | Return only the `ImageFormat` for a path, buffer, or stream |
| `probe(source)` | Probe a path, buffer, or stream, returning an `ImageInfo` |
| `probe_async(source)` | Asynchronous counterpart to `probe()` for asyncio applications |
| `ImageInfo` | Result type: `format`, `width`, `height`, `bit_depth`, `frame_count` |
| `ImageFormat` | Enum of the 14 supported formats, plus `UNKNOWN` |

## See Also
- [Aspose.Imaging — Enterprise Documentation](https://docs.aspose.com/imaging/)