Skip to content

Commit

Permalink
scripts/wrap_png.py: check if file exists before calling getsize
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Traneptora authored and mo271 committed Aug 6, 2024
1 parent 741cfb5 commit 22f95e4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion scripts/wrap_png.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 22f95e4

Please sign in to comment.