Skip to content

Commit

Permalink
docs: add comment
Browse files Browse the repository at this point in the history
  • Loading branch information
Joe-Heffer-Shef committed Jun 18, 2024
1 parent b0aafb8 commit e6ea209
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion scripts/btnp.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def get_args() -> argparse.Namespace:
parser.add_argument('-m', '--mean_exposure', default=0.18, type=float,
help='Target mean exposure (default: 0.18)')
parser.add_argument('-e', '--ext', default='.jpeg', help='Output file extension (default: .jpeg)')
# https://pillow.readthedocs.io/en/stable/handbook/concepts.html#concept-modes
parser.add_argument('-m', '--mode', default=None, help='PIL image mode. Default: L (8-bit pixels, grayscale)')

return parser.parse_args()

Expand All @@ -57,10 +59,11 @@ def main():
numpy.multiply(array, scale_factor, out=array, casting='unsafe')

# Convert to output image format
image = PIL.Image.fromarray(array)
image = PIL.Image.fromarray(obj=array, mode=args.mode)

# Save output
if not args.output_path:
# e.g. change "file.np" to "file.jpeg"
args.output_path = args.input_path.with_suffix(args.ext)
image.save(args.output_path)
logger.info("Wrote '%s'", args.output_path.absolute())
Expand Down

0 comments on commit e6ea209

Please sign in to comment.