parser.add_argument("file_dir",help="input folder of images")
parser.add_argument("output_dir",help="output folder to copy images to")
# args with defaults
parser.add_argument("-b","--bands",help="number of expected bands per capture",type=int,default=5)
parser.add_argument("-s","--sequential",help="use sequential capture group in filenames rather than original capture ID",type=bool,default=True)
parser.add_argument("-z","--zero_pad",help="if using sequential capture groups, zero-pad the group number to this many digits. 0 for no padding, -1 for auto padding",type=int,default=5)
parser.add_argument("-w","--whitespace_replace",help="replace whitespace characters with this character",type=str,default="-")
# optional args no defaults
parser.add_argument("-l","--logfile",help="write image metadata used to this CSV file",type=str)
parser.add_argument("-r","--replace_filename",help="use this instead of using the original filename in new filenames",type=str)
parser.add_argument("-f","--force",help="don't ask for confirmation",action="store_true")
parser.add_argument("-g","--no_grouping",help="do not apply grouping, only validate and add band name",action="store_true")
image_entry={"name":filename,"valid":True,"band":"-","ID":"-","group":0,"DateTime":"-","error":"-"}# dashes to ensure CSV exports properly, can be blank
try:
img=Image.open(old_path)
exceptPIL.UnidentifiedImageErrorasimg_err:
# if it tries importing a file it can't read as an image
# uncomment to print errors
# sys.stderr.write(str(img_err) + "\n")
no_exif_n+=1
iflogfile:
image_entry["valid"]=False
image_entry["error"]="Not readable as image: "+str(img_err)
# image_entry["band"] = "RGB" # TODO: we assume this. may not hold true for all datasets
no_exif_n+=1# this is just to keep a separate invalid message, comment out this whole if block and the jpgs shoud be handled by the "no capture ID" case
image_entry["valid"]=False
image_entry["error"]="RGB jpg, not counting for multispec processing"
images.append(image_entry)
# print(new_path) # debugging
print(str(no_exif_n)+" files were not multispectral images")