From 6c707775a6efd79924de0d56649f51163c82be96 Mon Sep 17 00:00:00 2001 From: Fusselkater Date: Fri, 11 Nov 2022 06:41:49 +0100 Subject: [PATCH] write part file and then replace output file --- lib/png_renderer.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/png_renderer.py b/lib/png_renderer.py index d8d1546..933bbdf 100644 --- a/lib/png_renderer.py +++ b/lib/png_renderer.py @@ -1,4 +1,5 @@ +import os from lib.renderer import Renderer from PIL import Image, ImageDraw, ImageFont, ImageFile @@ -41,4 +42,6 @@ class PNG_Renderer(Renderer): draw.text((text_x,artist_y), artist, font=artist_font, fill='#' + self._config['TitleFontColor']) draw.text((text_x,album_y), album, font=album_font, fill='#' + self._config['TitleFontColor']) - image.save(self._config['OutputPath']) \ No newline at end of file + # Write file and then move it in position + image.save(self._config['OutputPath'] + '.part', 'PNG') + os.replace(self._config['OutputPath'] + '.part', self._config['OutputPath']) \ No newline at end of file