diff --git a/autocrop/__version__.py b/autocrop/__version__.py index 7e207a2..3a909e8 100644 --- a/autocrop/__version__.py +++ b/autocrop/__version__.py @@ -3,4 +3,4 @@ __title__ = 'autocrop' __description__ = 'Automatically crops faces from batches of pictures' __author__ = 'François Leblanc' -__version__ = '0.1.4' +__version__ = '0.1.5' diff --git a/autocrop/autocrop.py b/autocrop/autocrop.py index ab0078f..89c0659 100644 --- a/autocrop/autocrop.py +++ b/autocrop/autocrop.py @@ -132,7 +132,8 @@ def main(path, fheight, fwidth): image = crop(input, fwidth, fheight) # Make sure there actually was a face in there - if image is None: + # Silly kludge: if image is None: + if isinstance(image, type(None)): print('No faces can be detected in file {}.'.format(str(file))) errors += 1 continue @@ -145,22 +146,22 @@ def main(path, fheight, fwidth): shutil.move(cropfilename, 'crop') # Stop and print timer - print(' {0} files have been cropped'.format(len(files_grabbed) - errors)) + print(' {} files have been cropped'.format(len(files_grabbed) - errors)) def cli(): - help_d = dict( - description='Automatically crops faces from batches of pictures', - path='Folder where images to crop are located. Default=photos/', - width='Width of cropped files in px. Default=500', - height='Height of cropped files in px. Default=500') - - parser = argparse.ArgumentParser(description=help_d.description) - parser.add_argument('-p', '--path', default='photos', help=help_d.path) + help_d = { + 'desc': 'Automatically crops faces from batches of pictures', + 'path': 'Folder where images to crop are located. Default=photos/', + 'width': 'Width of cropped files in px. Default=500', + 'height': 'Height of cropped files in px. Default=500'} + + parser = argparse.ArgumentParser(description=help_d['desc']) + parser.add_argument('-p', '--path', default='photos', help=help_d['path']) parser.add_argument('-w', '--width', type=int, - default=500, help=help_d.width) + default=500, help=help_d['width']) parser.add_argument('-H', '--height', - type=int, default=500, help=help_d.height) + type=int, default=500, help=help_d['height']) parser.add_argument('-v', '--version', action='version', version='%(prog)s version {}'.format(__version__))