fitstopnm

Convert a Flexible Image Transport System (FITS) file to a PNM image. See also: pamtofits. More information: https://netpbm.sourceforge.net/doc/fitstopnm.html.

fitstopnm path/to/file.fits > path/to/output.pnm

fitstopnm -image z_position path/to/file.fits > path/to/output.pnm