:param fh: File handle. :param bufsize: Buffer size. :returns: If finished successfully, return 0. Otherwise, return an error code. Err codes are from :data:`.ImageFile.ERRORS`.
(self, fh: int, bufsize: int)
| 922 | return bytes_consumed, errcode |
| 923 | |
| 924 | def encode_to_file(self, fh: int, bufsize: int) -> int: |
| 925 | """ |
| 926 | :param fh: File handle. |
| 927 | :param bufsize: Buffer size. |
| 928 | |
| 929 | :returns: If finished successfully, return 0. |
| 930 | Otherwise, return an error code. Err codes are from |
| 931 | :data:`.ImageFile.ERRORS`. |
| 932 | """ |
| 933 | errcode = 0 |
| 934 | while errcode == 0: |
| 935 | status, errcode, buf = self.encode(bufsize) |
| 936 | if status > 0: |
| 937 | os.write(fh, buf[status:]) |
| 938 | return errcode |