Skip to content

Commit

Permalink
Bugfixes (#23)
Browse files Browse the repository at this point in the history
* Update autocrop.py

Sundeep fixed the bug and it's working now

* PEP8

* properly handle image == None
  • Loading branch information
leblancfg authored Oct 3, 2017
1 parent 175af1d commit e2a41e3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion autocrop/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
25 changes: 13 additions & 12 deletions autocrop/autocrop.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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__))

Expand Down

0 comments on commit e2a41e3

Please sign in to comment.