def fromfits(infile, hdu = 0, verbose = True):
    """
    Factory function that reads a FITS file and returns a f2nimage object.
    Use hdu to specify which HDU you want (primary = 0)
    """
    
    pixelarray, hdr = ft.getdata(infile, hdu, header=True)
    pixelarray = np.asarray(pixelarray).transpose()
    #print pixelarray
    
    pixelarrayshape = pixelarray.shape
    if verbose :
        print "Input shape : (%i, %i)" % (pixelarrayshape[0], pixelarrayshape[1])
        print "Input file BITPIX : %s" % (hdr["BITPIX"])
    pixelarrayshape = np.asarray(pixelarrayshape)
    if verbose :
        print "Internal array type :", pixelarray.dtype.name
    
    return f2nimage(pixelarray, verbose = verbose)