andrewning / sortphotos

SortPhotos is a Python script that organizes photos and videos into folders using date/time information

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ValueError: invalid literal for int() with base 10: ''

andreaseberharter opened this issue · comments

I ran the script on a folder with 450GB of images (totally messed up):
sortphotos --recursive /messy_images /organised_images

and received the following Error after processing and moving around 40GB:

Traceback (most recent call last):
File "/usr/local/bin/sortphotos", line 9, in
load_entry_point('sortphotos==1.0', 'console_scripts', 'sortphotos')()
File "/Library/Python/2.7/site-packages/sortphotos-1.0-py2.7.egg/src/sortphotos.py", line 484, in main
args.use_only_tags, not args.silent)
File "/Library/Python/2.7/site-packages/sortphotos-1.0-py2.7.egg/src/sortphotos.py", line 310, in sortPhotos
src_file, date, keys = get_oldest_timestamp(data, additional_groups_to_ignore, additional_tags_to_ignore)
File "/Library/Python/2.7/site-packages/sortphotos-1.0-py2.7.egg/src/sortphotos.py", line 145, in get_oldest_timestamp
exifdate = parse_date_exif(date)
File "/Library/Python/2.7/site-packages/sortphotos-1.0-py2.7.egg/src/sortphotos.py", line 73, in parse_date_exif
minute = int(time[1])
ValueError: invalid literal for int() with base 10: ''

Any idea? Thank you for you help in advance.
Btw. love the script, really nice work! Thanks. Andreas

If you are able to isolate a photo that causes the problem, and can send that over, that would be super helpful.

On Tue, Nov 3, 2015 at 6:19 AM, Andreas Eberharter
notifications@github.com wrote:

I ran the script on a folder with 450GB of images (totally messed up):
sortphotos --recursive /messy_images /organised_images
and received the following Error after processing and moving around 40GB:
Traceback (most recent call last):
File "/usr/local/bin/sortphotos", line 9, in
load_entry_point('sortphotos==1.0', 'console_scripts', 'sortphotos')()
File "/Library/Python/2.7/site-packages/sortphotos-1.0-py2.7.egg/src/sortphotos.py", line 484, in main
args.use_only_tags, not args.silent)
File "/Library/Python/2.7/site-packages/sortphotos-1.0-py2.7.egg/src/sortphotos.py", line 310, in sortPhotos
src_file, date, keys = get_oldest_timestamp(data, additional_groups_to_ignore, additional_tags_to_ignore)
File "/Library/Python/2.7/site-packages/sortphotos-1.0-py2.7.egg/src/sortphotos.py", line 145, in get_oldest_timestamp
exifdate = parse_date_exif(date)
File "/Library/Python/2.7/site-packages/sortphotos-1.0-py2.7.egg/src/sortphotos.py", line 73, in parse_date_exif
minute = int(time[1])
ValueError: invalid literal for int() with base 10: ''

Any idea, seems something is messed up with the oldest_timestamp. Thank you for you help in advance. Andreas

Reply to this email directly or view it on GitHub:
#63

Thank you Andrew for your quick reply. I managed to find the image, TIF

$ sortphotos --recursive Desktop/test Desktop/test_result

Preprocessing with ExifTool. May take a while for a large number of files.
1 directories scanned
1 image files read
[{
"SourceFile": "Desktop/test/TMP1.TIF",
"File:FileModifyDate": "2005:11:21 02:11:49+00:00",
"File:FileAccessDate": "2015:11:03 22:57:33+00:00",
"File:FileInodeChangeDate": "2015:11:03 22:04:07+00:00",
"EXIF:ModifyDate": "2005:11:21 0: 6:55"
}]
{ready}

Traceback (most recent call last):
File "/usr/local/bin/sortphotos", line 9, in
load_entry_point('sortphotos==1.0', 'console_scripts', 'sortphotos')()
File "/Library/Python/2.7/site-packages/sortphotos-1.0-py2.7.egg/src/sortphotos.py", line 484, in main
args.use_only_tags, not args.silent)
File "/Library/Python/2.7/site-packages/sortphotos-1.0-py2.7.egg/src/sortphotos.py", line 310, in sortPhotos
src_file, date, keys = get_oldest_timestamp(data, additional_groups_to_ignore, additional_tags_to_ignore)
File "/Library/Python/2.7/site-packages/sortphotos-1.0-py2.7.egg/src/sortphotos.py", line 145, in get_oldest_timestamp
exifdate = parse_date_exif(date)
File "/Library/Python/2.7/site-packages/sortphotos-1.0-py2.7.egg/src/sortphotos.py", line 73, in parse_date_exif
minute = int(time[1])
ValueError: invalid literal for int() with base 10: ''

If I recall correctly the image was created with a SANE scan under linux.

The problem is the EXIF data for this image is poorly formed:

"EXIF:ModifyDate": "2005:11:21 0: 6:55”

there shouldn’t be a space before the 6 so it can’t read the time correctlly.  I added a fix that will work, but it ignores the time (but doesn’t ignore the date information which is valid).  It’s a bit harder to handle trying to fix all the possible ways malformed data could be input.  Usually my advice is to fix the exif data manually using exiftool (or other exif editors) once and for all, because it’s going to be a problem for other programs that try to process this photo.

On Tue, Nov 3, 2015 at 5:15 PM, Andreas Eberharter
notifications@github.com wrote:

Thank you Andrew for your quick reply. I managed to find the image, TIF
$ sortphotos --recursive Desktop/test Desktop/test_result

Preprocessing with ExifTool. May take a while for a large number of files.
1 directories scanned
1 image files read
[{
"SourceFile": "Desktop/test/TMP1.TIF",
"File:FileModifyDate": "2005:11:21 02:11:49+00:00",
"File:FileAccessDate": "2015:11:03 22:57:33+00:00",
"File:FileInodeChangeDate": "2015:11:03 22:04:07+00:00",
"EXIF:ModifyDate": "2005:11:21 0: 6:55"
}]
{ready}
Traceback (most recent call last):
File "/usr/local/bin/sortphotos", line 9, in
load_entry_point('sortphotos==1.0', 'console_scripts', 'sortphotos')()
File "/Library/Python/2.7/site-packages/sortphotos-1.0-py2.7.egg/src/sortphotos.py", line 484, in main
args.use_only_tags, not args.silent)
File "/Library/Python/2.7/site-packages/sortphotos-1.0-py2.7.egg/src/sortphotos.py", line 310, in sortPhotos
src_file, date, keys = get_oldest_timestamp(data, additional_groups_to_ignore, additional_tags_to_ignore)
File "/Library/Python/2.7/site-packages/sortphotos-1.0-py2.7.egg/src/sortphotos.py", line 145, in get_oldest_timestamp
exifdate = parse_date_exif(date)
File "/Library/Python/2.7/site-packages/sortphotos-1.0-py2.7.egg/src/sortphotos.py", line 73, in parse_date_exif
minute = int(time[1])
ValueError: invalid literal for int() with base 10: ''

If I recall correctly the image was created with a SANE scan under linux.

Reply to this email directly or view it on GitHub:
#63 (comment)

fixed with 05eca3c

Thank you for the quick fix.
Maybe it is possible to catch these problematic files and skip them and show an error array after completing all the other files? If that makes sense.