Clarify variable names in ImageFile

Co-authored-by: Yay295 <Yay295@users.noreply.github.com>
This commit is contained in:
Aarni Koskela 2023-02-24 10:04:38 +02:00
parent b6b72170a8
commit 04be46d484

View File

@ -530,20 +530,20 @@ def _encode_tile(im, fp, tile, bufsize, fh, exc=None):
encoder.setimage(im.im, b)
if encoder.pushes_fd:
encoder.setfd(fp)
l, s = encoder.encode_to_pyfd()
length, error_code = encoder.encode_to_pyfd()
else:
if exc:
# compress to Python file-compatible object
while True:
l, s, d = encoder.encode(bufsize)
fp.write(d)
if s:
length, error_code, chunk = encoder.encode(bufsize)
fp.write(chunk)
if error_code:
break
else:
# slight speedup: compress to real file object
s = encoder.encode_to_file(fh, bufsize)
if s < 0:
msg = f"encoder error {s} when writing image file"
error_code = encoder.encode_to_file(fh, bufsize)
if error_code < 0:
msg = f"encoder error {error_code} when writing image file"
raise OSError(msg) from exc
finally:
encoder.cleanup()