Skip to content

Commit

Permalink
Explicit error check.
Browse files Browse the repository at this point in the history
  • Loading branch information
athas committed Jan 1, 2025
1 parent 7c296a8 commit 7ad7d72
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tools/data2png.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# [height][width]u32
#
# [height][width]f32
# [height][width]f64
#
# [height][width][3]i8
# [height][width][3]u8
Expand All @@ -24,6 +25,10 @@
import numpy as np
import png

if "purepng" not in png.__file__:
print("data2png works only with purepng, not pypng.", file=sys.stderr)
sys.exit(1)


def read_image(f):
# Skip binary header.
Expand Down Expand Up @@ -93,7 +98,6 @@ def read_image(f):

with open(infile, "rb") as f_in:
width, height, img = read_image(f_in)

with open(outfile, "wb") as f_out:
w = png.Writer(width=width, height=height, alpha=False)
w.write(f_out, img)

0 comments on commit 7ad7d72

Please sign in to comment.