Add option to select quality measurement method to use
This commit is contained in:
parent
05e077105a
commit
7a186ec82e
@ -50,17 +50,20 @@ class imgrate:
|
||||
|
||||
if __name__ == '__main__':
|
||||
from os import remove
|
||||
from sys import exit
|
||||
|
||||
def parse_arguments():
|
||||
ap = ArgumentParser()
|
||||
ap.add_argument('images', type=str, nargs='+', help='')
|
||||
ap.add_argument('-d', '--delete', action='store_true', help='Delete all but the best quality image.')
|
||||
ap.add_argument('-q', '--quiet', action='store_true', help='Print quality measurements only.')
|
||||
ap.add_argument('-m', '--method', type=str, default='quality', help='Select quality measurement to use.')
|
||||
return ap.parse_args()
|
||||
|
||||
|
||||
def run(args):
|
||||
ratings = {image: imgrate(image).quality for image in args.images}
|
||||
try: ratings = {image: getattr(imgrate(image), args.method) for image in args.images}
|
||||
except AttributeError: exit('Invalid --method option!')
|
||||
maximum = max(ratings, key=ratings.get)
|
||||
|
||||
for rating in ratings.keys():
|
||||
|
Loading…
Reference in New Issue
Block a user