Crate nitf_rs

source ·
Expand description

Minimal Crate for reading and manipulating NITF files Interface for NITF version 2.1

Constructing a Nitf object parses the header and subheader information. Each segment in contains a meta field which stores the respective fields defined in the file standard. The primary function for constructing a Nitf is read_nitf()

// Read a nitf file and dump metadata to stdout
use std::path::Path;
let nitf_path = Path::new("../example.nitf");
let nitf = nitf_rs::read_nitf(&nitf_path);
println!("{nitf}");

The main feature of the FileHeader is its meta field (see (NitfHeader) headers::NitfHeader). All other segments use the generic NitfSegment to provide header fields and a memory-map of the segment data.

// Get the bytes from the first image segment
use std::path::Path;
let nitf_path = Path::new("../example.nitf");
let nitf = nitf_rs::read_nitf(&nitf_path);
let im_seg = &nitf.image_segments[0];
let u8_slice = &im_seg.data[..];

Most metadata elements are stored in a NitfField structure. This structure stores the bytes which encode the value, a string representation, and a val which holds on to native value of the field (i.e., the bytes parsed into a u8, u16, String, enum, etc.)

// Read in a nitf and extract the...
use std::path::Path;
let nitf_path = Path::new("../example.nitf");
let nitf = nitf_rs::read_nitf(&nitf_path);
// .. File title
let file_title = nitf.nitf_header.meta.ftitle.val;
// .. Number of image segments
let n_img_segments = nitf.nitf_header.meta.numi.val;
// .. and number of rows in the first image segment data
let n_rows = nitf.image_segments[0].meta.nrows.val;

If there is user-defined tagged-record-extension (TRE) data within a segment, it is stored in an ExtendedSubheader for the user to parse accordingly.

Modules

  • Header metadata definitions
  • File header and generic segment definition
  • Common types use throughout

Structs

  • Top level NITF interface

Functions