Fixed EXIF longitude bug
- Negative or 'W' longitudes were not accounted for. - pyflakes fixes.
This commit is contained in:
parent
b105540141
commit
c72d661bed
@ -30,7 +30,8 @@ _log = logging.getLogger(__name__)
|
||||
|
||||
def resize_image(entry, filename, new_path, exif_tags, workdir, new_size,
|
||||
size_limits=(0, 0)):
|
||||
"""Store a resized version of an image and return its pathname.
|
||||
"""
|
||||
Store a resized version of an image and return its pathname.
|
||||
|
||||
Arguments:
|
||||
entry -- the entry for the image to resize
|
||||
|
@ -32,6 +32,7 @@ USEFUL_TAGS = [
|
||||
'EXIF UserComment',
|
||||
]
|
||||
|
||||
|
||||
def exif_image_needs_rotation(exif_tags):
|
||||
"""
|
||||
Returns True if EXIF orientation requires rotation
|
||||
@ -39,6 +40,7 @@ def exif_image_needs_rotation(exif_tags):
|
||||
return 'Image Orientation' in exif_tags \
|
||||
and exif_tags['Image Orientation'].values[0] != 1
|
||||
|
||||
|
||||
def exif_fix_image_orientation(im, exif_tags):
|
||||
"""
|
||||
Translate any EXIF orientation to raw orientation
|
||||
@ -47,7 +49,7 @@ def exif_fix_image_orientation(im, exif_tags):
|
||||
- REDUCES IMAGE QUALITY by recompressig it
|
||||
|
||||
Pros:
|
||||
- Cures my neck pain
|
||||
- Prevents neck pain
|
||||
"""
|
||||
# Rotate image
|
||||
if 'Image Orientation' in exif_tags:
|
||||
@ -62,6 +64,7 @@ def exif_fix_image_orientation(im, exif_tags):
|
||||
|
||||
return im
|
||||
|
||||
|
||||
def extract_exif(filename):
|
||||
"""
|
||||
Returns EXIF tags found in file at ``filename``
|
||||
@ -76,6 +79,7 @@ def extract_exif(filename):
|
||||
|
||||
return exif_tags
|
||||
|
||||
|
||||
def clean_exif(exif):
|
||||
'''
|
||||
Clean the result from anything the database cannot handle
|
||||
@ -96,6 +100,7 @@ def clean_exif(exif):
|
||||
|
||||
return clean_exif
|
||||
|
||||
|
||||
def _ifd_tag_to_dict(tag):
|
||||
data = {
|
||||
'printable': tag.printable,
|
||||
@ -117,9 +122,11 @@ def _ifd_tag_to_dict(tag):
|
||||
|
||||
return data
|
||||
|
||||
|
||||
def _ratio_to_list(ratio):
|
||||
return [ratio.num, ratio.den]
|
||||
|
||||
|
||||
def get_useful(tags):
|
||||
useful = {}
|
||||
for key, tag in tags.items():
|
||||
@ -127,7 +134,7 @@ def get_useful(tags):
|
||||
useful[key] = tag
|
||||
|
||||
return useful
|
||||
|
||||
|
||||
|
||||
def get_gps_data(tags):
|
||||
"""
|
||||
@ -147,9 +154,13 @@ def get_gps_data(tags):
|
||||
gps_data[key] = (
|
||||
lambda v:
|
||||
float(v[0].num) / float(v[0].den) \
|
||||
+ (float(v[1].num) / float(v[1].den) / 60 )\
|
||||
+ (float(v[1].num) / float(v[1].den) / 60) \
|
||||
+ (float(v[2].num) / float(v[2].den) / (60 * 60))
|
||||
)(dat.values)
|
||||
|
||||
if tags['GPS GPSLongitudeRef'].values == 'W':
|
||||
gps_data['longitude'] /= -1
|
||||
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user