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 file header and segment metadata. Each segment in contains a header field which stores the respective metadata defined in the file standard. The primary function for constructing a Nitf is Nitf::from_reader()

// Read a nitf file and dump metadata to stdout
let mut nitf_file = std::fs::File::open("example.nitf").unwrap();
let nitf = nitf_rs::Nitf::from_reader(&mut nitf_file).unwrap();
println!("{nitf}");

Aside from the nitf_header, all other segments use a generic [NitfSegment] to provide metadata and access to the segment data.

// Get the bytes from the first image segment
let mut nitf_file = std::fs::File::open("example.nitf").unwrap();
let nitf = nitf_rs::Nitf::from_reader(&mut nitf_file).unwrap();
let im_seg = &nitf.image_segments[0];
let im_seg_hdr = &im_seg.header;
let im_seg_data = &im_seg.get_data_map(&mut nitf_file).unwrap();

Most metadata elements are stored in a NitfField structure. This structure has a val which holds on to native value of the field (i.e., the bytes parsed into a u8, u16, String, enum, etc.), as well as the length (in bytes) and name of the field.

let mut nitf_file = std::fs::File::open("example.nitf").unwrap();
let nitf = nitf_rs::Nitf::from_reader(&mut nitf_file).unwrap();
let file_title = nitf.nitf_header.ftitle.val;
let n_img_segments = nitf.nitf_header.numi.val;
let n_rows = nitf.image_segments[0].header.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
  • Common types use throughout

Structs§

  • Top level NITF interface

Enums§

Type Aliases§