[fitsbits] question with image dimesions

Doug Mink dmink at cfa.harvard.edu
Thu Nov 14 14:55:44 EST 2002


"mike333_n at yahoo.com" wrote:
> 
> can one programmatically (c or c++) figure image height and width?.
> (actual pixel area).

The CFITSIO or WCSTools libraries have subroutines which can read FITS
headers and extract information by returning the values of header keywords,
such as width (NAXIS1) and height (NAXIS2).

In WCSTools, the code would be:

#include "fitsfile.h"

    ...

    char *filename;
    char *header; /* FITS header (returned) */
    int nbhead;	/* Number of bytes before start of data (returned) */
    int lhead;	/* Allocated length of FITS header in bytes (returned) */
    int nx, ny;	/* Horizontal and vertical dimensions of the image */

    header = fitsrhead (filename, &lhead, &nbhead);
    nx = 0;
    hgeti4 (header, "NAXIS1", &nx); /* nx is set only if NAXIS1 is present */
    ny = 0;
    hgeti4 (header, "NAXIS2", &ny); /* ny is set only if NAXIS2 is present */

    ...


-Doug Mink




More information about the fitsbits mailing list