def _fromfile(self, fh):
        """Initialize instance from open file."""
        fh.seek(0)
        data = fh.read(4096)
        if (len(data) < 7) or not (b'0' < data[1:2] < b'8'):
            raise ValueError("Not a Netpbm file:\n%s" % data[:32])
        try:
            self._read_pam_header(data)
        except Exception:
            try:
                self._read_pnm_header(data)
            except Exception:
                raise ValueError("Not a Netpbm file:\n%s" % data[:32])
def _fromfile ( self , fh ) : fh . seek ( 0 ) data = fh . read ( 4096 ) if ( len ( data ) < 7 ) or not ( b'0' < data [ 1 : 2 ] < b'8' ) : raise ValueError ( "Not a Netpbm file:\n%s" % data [ : 32 ] ) try : self . _read_pam_header ( data ) except Exception : try : self . _read_pnm_header ( data ) except Exception : raise ValueError ( "Not a Netpbm file:\n%s" % data [ : 32 ] )
Initialize instance from open file.