OrbitalCommons / projects / fitsio-pure
Store · Rust crate
fitsio-pure
Read and write FITS images, headers, and tables without a C library. Bring the same file format to native applications and the browser.
Inspect a FITS file locallySpace data. Pure Rust.
FITS is a foundation of astronomical imaging.
fitsio-pure makes those files accessible through
a Rust implementation with no C dependencies and no unsafe code.
Its core works with alloc; filesystem and
compatibility APIs are optional.
Native Rust
Build without a system installation of CFITSIO or a C toolchain.
Images + tables
Read and write standard image types, binary tables, ASCII tables, and header keywords.
Bytes in, data out
Parse an in-memory buffer, including a file opened directly in a browser.
Inspect a FITS file in your browser
Open a synthetic star field or inspect your own FITS file. The real fitsio-pure 0.13.5 parser runs here as WebAssembly. Your file stays in your browser.
Inspect headers, dimensions, and an image preview.
Uncompressed
FITS files, up to 16 MiB.
Enable JavaScript to run the FITS workbench.
Explore header cards
| Keyword | Value | Comment |
|---|
This compact viewer shows the primary header and previews uncompressed 2D primary images up to 4 million pixels. The library supports more formats and extensions. Download the synthetic sample · Demo source
Add FITS to your Rust project
cargo add fitsio-pure
For a familiar fitsio-style API, enable the optional
compatibility layer:
cargo add fitsio-pure --features compat
Read your first FITS header
use fitsio_pure::{hdu::parse_fits, image::read_image_data};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let bytes = std::fs::read("image.fits")?;
let fits = parse_fits(&bytes)?;
let image = read_image_data(&bytes, fits.primary())?;
println!("{} HDUs; pixels: {image:?}", fits.hdus.len());
Ok(())
}
read_image_data returns raw typed pixels. Apply
header scaling when you need calibrated values. In a browser,
provide the file’s bytes instead of reading from a filesystem.
One format, many kinds of data
| Feature | Default | Purpose |
|---|---|---|
std |
Yes | Standard library support. |
compat |
No | A familiar fitsio-style API, including in-memory files. |
array |
No | ndarray integration, with the compatibility layer. |
cli |
No | The fitsinfo and fitsconv command-line tools. |
Image types include unsigned 8-bit, signed 16/32/64-bit, and 32/64-bit floating point. The core also reads RICE_1 and GZIP_1 tile-compressed images. Read the migration guide →
Examples and feature notes reviewed against fitsio-pure 0.13.5. Source & contributions →
Find where an astronomical image belongs.