summaryrefslogtreecommitdiff
path: root/kvmd/apps/vnc
diff options
context:
space:
mode:
authorMaxim Devaev <[email protected]>2022-01-17 13:54:52 +0300
committerMaxim Devaev <[email protected]>2022-01-17 13:54:52 +0300
commit3ee1948f19ca3e1a3d396e29dc902aeec4402479 (patch)
tree422e942bd341440339c6fbd4b960729a93fdce27 /kvmd/apps/vnc
parent902fc38778404e3729324a8bccc724b7d977acdf (diff)
refactoring
Diffstat (limited to 'kvmd/apps/vnc')
-rw-r--r--kvmd/apps/vnc/render.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/kvmd/apps/vnc/render.py b/kvmd/apps/vnc/render.py
index fc07a2a9..a443e34e 100644
--- a/kvmd/apps/vnc/render.py
+++ b/kvmd/apps/vnc/render.py
@@ -25,9 +25,9 @@ import os
import io
import functools
-from PIL import Image
-from PIL import ImageDraw
-from PIL import ImageFont
+from PIL import Image as PilImage
+from PIL import ImageDraw as PilImageDraw
+from PIL import ImageFont as PilImageFont
from ... import aiotools
@@ -39,8 +39,8 @@ async def make_text_jpeg(width: int, height: int, quality: int, text: str) -> by
@functools.lru_cache(maxsize=10)
def _inner_make_text_jpeg(width: int, height: int, quality: int, text: str) -> bytes:
- image = Image.new("RGB", (width, height), color=(0, 0, 0))
- draw = ImageDraw.Draw(image)
+ image = PilImage.new("RGB", (width, height), color=(0, 0, 0))
+ draw = PilImageDraw.Draw(image)
draw.multiline_text((20, 20), text, font=_get_font(), fill=(255, 255, 255))
with io.BytesIO() as bio:
image.save(bio, format="jpeg", quality=quality)
@@ -48,8 +48,8 @@ def _inner_make_text_jpeg(width: int, height: int, quality: int, text: str) -> b
@functools.lru_cache()
-def _get_font() -> ImageFont.FreeTypeFont:
+def _get_font() -> PilImageFont.FreeTypeFont:
module_path = sys.modules[__name__].__file__
assert module_path is not None
path = os.path.join(os.path.dirname(module_path), "fonts", "Azbuka04.ttf")
- return ImageFont.truetype(path, size=20)
+ return PilImageFont.truetype(path, size=20)