Better error message when __convert_image__ fails to write output
This commit is contained in:
parent
08931a9aba
commit
31fad78829
1 changed files with 4 additions and 2 deletions
|
|
@ -69,8 +69,10 @@ def render_image(self, src_path: str, output_path: str) -> None:
|
|||
import subprocess
|
||||
with open(src_path, 'rb') as src, open(output_path, 'wb', opener=partial(os.open, mode=stat.S_IREAD | stat.S_IWRITE)) as output:
|
||||
cp = subprocess.run([kitten_exe(), '__convert_image__', 'RGBA'], stdin=src, stdout=output, stderr=subprocess.PIPE)
|
||||
if cp.returncode != 0:
|
||||
raise ValueError(f'Failed to convert path to RGBA data with error: {cp.stderr.decode("utf-8", "replace")}')
|
||||
if cp.returncode != 0:
|
||||
raise ValueError(f'Failed to convert {src_path} to RGBA data with error: {cp.stderr.decode("utf-8", "replace")}')
|
||||
if output.seek(0, os.SEEK_END) < 8:
|
||||
raise ValueError(f'Failed to convert {src_path} to RGBA data, no output written. stderr: {cp.stderr.decode("utf-8", "replace")}')
|
||||
|
||||
def read_metadata(self, output_path: str) -> tuple[int, int, int]:
|
||||
with open(output_path, 'rb') as f:
|
||||
|
|
|
|||
Loading…
Reference in a new issue