diff options
author | Devaev Maxim <[email protected]> | 2020-05-29 18:53:17 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2020-05-29 18:53:17 +0300 |
commit | a5fcafe2a5a1bd8e18df9b96e2185d1979fc9977 (patch) | |
tree | 46209afd53b16d07387a48154519ad11c1c8355e | |
parent | 3389dbe0481515b6625359c17105a27cb8dfa93a (diff) |
image context manager
-rw-r--r-- | kvmd/apps/vnc/render.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/kvmd/apps/vnc/render.py b/kvmd/apps/vnc/render.py index f65f1405..f42840a8 100644 --- a/kvmd/apps/vnc/render.py +++ b/kvmd/apps/vnc/render.py @@ -42,9 +42,9 @@ def _inner_make_text_jpeg(width: int, height: int, quality: int, text: str) -> b image = Image.new("RGB", (width, height), color=(0, 0, 0)) draw = ImageDraw.Draw(image) draw.multiline_text((20, 20), text, font=_get_font(), fill=(255, 255, 255)) - bio = io.BytesIO() - image.save(bio, format="jpeg", quality=quality) - return bio.getvalue() + with io.BytesIO() as bio: + image.save(bio, format="jpeg", quality=quality) + return bio.getvalue() @functools.lru_cache() |