def _fromfile(self, fh):
fh.seek(<NUM_LIT:0>)<EOL>data = fh.read(<NUM_LIT>)<EOL>if (len(data) < <NUM_LIT:7>) or not (b'<STR_LIT:0>' < data[<NUM_LIT:1>:<NUM_LIT:2>] < b'<STR_LIT>'):<EOL><INDENT>raise ValueError("<STR_LIT>" % data[:<NUM_LIT:32>])<EOL><DEDENT>try:<EOL><INDENT>self._read_pam_header(data)<EOL><DEDENT>except Exception:<EOL><INDENT>try:<EOL><INDENT>self._read_pnm_header(data)<EOL><DEDENT>except Exception:<EOL><INDENT>raise ValueError("<STR_LIT>" % data[:<NUM_LIT:32>])<EOL><DEDENT><DEDENT>
Initialize instance from open file.