From 22f95e4abd90c3823fc0e376c87e908a11dd7e56 Mon Sep 17 00:00:00 2001 From: Leo Izen Date: Tue, 6 Aug 2024 06:20:50 -0400 Subject: [PATCH] scripts/wrap_png.py: check if file exists before calling getsize On some platforms (e.g. Linux), os.file.getsize throws an exception rather than returning zero if the file doesn't exist. We check for this as well before we spit out a dummy ICC profile, or numpy will report no frame data on those files. Signed-off-by: Leo Izen --- scripts/wrap_png.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/wrap_png.py b/scripts/wrap_png.py index b522fc5..aca4c73 100644 --- a/scripts/wrap_png.py +++ b/scripts/wrap_png.py @@ -45,7 +45,7 @@ def write_orig_icc(args): # TODO(jon): make this also work for PNG files that use other ways to signal their colorspace def write_icc(temp_file, args, nbchans): subprocess.run(["convert", temp_file.name, args.icc_out]) - if (os.path.getsize(args.icc_out) == 0): + if not os.path.exists(args.icc_out) or os.path.getsize(args.icc_out) == 0: if nbchans >= 3: with open('scripts/sRGB.icc', 'rb') as file: binary_data = file.read()