Introduction
pds2img reads image products from the NASA Planetary Data System (PDS) and exports them as 16-bit grayscale PNG or TIFF files. It runs in browsers and in Node.js.

What it supports
See Supported formats for the complete list of keywords and data types.
How the conversion works
- Parse the label. A PDS3 label is parsed into a plain object; a PDS4 label is parsed into an XML
Document. - Locate the pixels. The library reads the image size, sample type, byte order, line prefix bytes and the byte offset of the image inside the data file.
- Calibrate. Each raw sample is converted to a physical value with
raw × scale + offset. In PDS3 products, samples equal toINVALID_CONSTANTorMISSING_CONSTANTbecomeNaN. - Encode. The finite values are linearly mapped to
0…65535and written as an uncompressed 16-bit grayscale PNG or TIFF.NaNpixels are written as0.
The output keeps the full dynamic range of the source data. A display-oriented 8-bit image would lose some of it.
Design
The public API is a small facade:
- Loaders turn files, buffers or URLs into an image object:
loadPDS3Image,loadPDS4Imageand theirByFile/ByUrlvariants. - Encoders turn an image object into a file:
toPNGandtoTIFF.
Label parsing, binary decoding and byte-order handling are internal. The low-level classes (PDS3Image, PDS4Image) and parsers (parseLBL, parseXML) are still exported for advanced use.
Next steps
- Getting started: install the package and convert your first image.
- Playground: try it in the browser with your own files.