Commit 3e237780 authored by Saad Jbabdi's avatar Saad Jbabdi
Browse files

initial commit

parent 6b18a3e4
#!/usr/bin/env python
import tifffile as tif
import argparse
class ImageHelper(object):
def __init__(self, filename = None):
self.filename = filename
self.header = None
if filename is not None:
self.header = tif.TiffFile(self.filename)
def summary(self,width=False,length=False):
if self.header is None:
print('--- NO IMAGE HAS BEEN READ ---')
else:
shape = self.header.pages[0].shape
if(width):
print(shape[1])
if(length):
print(shape[0])
if(not width and not length):
print('------------------------')
print('File name : {}'.format(self.filename))
print('Dimensions : {}x{}'.format(shape[0],shape[1]))
print('------------------------')
return
def main():
p = argparse.ArgumentParser(description='Quick image info')
# Optional arguments
# Required arguments
p.add_argument('image',
type=str, nargs='*', metavar='<str>.tiff [<str>.tiff ...] ',
help='input image or list of images')
p.add_argument('--width',action='store_true',
default=False, dest='boolean_w',
help='get width')
p.add_argument('--length',action='store_true',
default=False, dest='boolean_l',
help='get length')
# Parse arguments
args = p.parse_args()
for img in args.image:
#print(img)
ih = ImageHelper(img)
if not args.boolean_w and not args.boolean_l:
ih.summary()
else:
if(args.boolean_w):
ih.summary(width=True)
if(args.boolean_l):
ih.summary(length=True)
if __name__ == '__main__':
main()
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