FabIO - I/O library for X-ray detector images
raw JSON → 2025.10.0 verified Fri May 01 auth: no python
FabIO is a Python library for reading and writing images produced by 2D X-ray detectors. It supports over 20 file formats (e.g., EDF, Mar, Pilatus, TIFF, HDF5). Version 2025.10.0 requires Python >=3.10. Release cadence is roughly monthly, with versioning based on date (YYYY.MINOR.PATCH).
pip install fabio Common errors
error ModuleNotFoundError: No module named 'fabio' ↓
cause FabIO is not installed, or installed in a different environment.
fix
Run 'pip install fabio' in your active Python environment.
error fabio.fabioimage.FabIOImage cannot be instantiated directly ↓
cause FabIOImage is an abstract base class; users mistakenly try to instantiate it.
fix
Use a concrete subclass like 'from fabio.edfimage import EdfImage' or obtain an image via 'fabio.openimage()'.
error AttributeError: 'NoneType' object has no attribute 'data' ↓
cause openimage() returns None if the file is not recognized. User assumes it always returns an image object.
fix
Check the return value: 'img = fabio.openimage(filename); if img is None: raise IOError("Unsupported format")'.
Warnings
breaking In version 2020.x, the 'cbf' module was refactored. Import paths for CBF-specific readers have changed. Use 'from fabio.cbfimage import CbfImage' instead of old 'from fabio.cbf import Cbf'. Affects code written before 2020. ↓
fix Update imports to use 'fabio.<format>image' submodule pattern.
deprecated The 'fabio.input' and 'fabio.output' modules are deprecated since version 2023. Use the format-specific image classes (e.g., EdfImage, Mar345Image) directly. ↓
fix Replace 'from fabio.input import EdfInput' with 'from fabio.edfimage import EdfImage' and use the object's methods.
gotcha FabIO's openimage() does not guess the file format from extension alone; it reads the header. If the file is malformed, it may raise an unexpected error. ↓
fix Wrap openimage() in a try/except to catch IOError or ValueError. Validate files offline with 'fabio -c file.edf' command-line tool.
Install
conda install -c conda-forge fabio Imports
- fabio
import fabio - openimage wrong
from fabio import openimagecorrectfabio.openimage(filename)
Quickstart
import fabio
import numpy as np
# Read an image
img = fabio.openimage('example.edf')
data = img.data
print('Shape:', data.shape)
# Create and write a simple image
from fabio.edfimage import EdfImage
new_data = np.random.rand(100, 100)
new_img = EdfImage(data=new_data)
new_img.write('output.edf')
print('Written output.edf')