Initial import of script

parent d1614b98
# Author: Ghislain Antony Vaillant <g.vaillant@imperial.ac.uk>
from argparse import ArgumentParser
from nibabel import load
from PIL import Image
parser = ArgumentParser(prog='nithumb',
description='Generate a thumbnail from a NIfTI file')
parser.add_argument('inputfile', help='Input NIfTI file')
parser.add_argument('thumbnail', help='Output thumbnail')
parsed = parser.parse_args()
image = load(parsed.inputfile).get_data()
image = Image.fromarray(image[:, :, 0] if image.ndim == 3 else image)
image = image.resize([128, 128])
image.save(parsed.thumbnail)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment