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,
|
def resize_image(entry, filename, new_path, exif_tags, workdir, new_size,
|
||||||
size_limits=(0, 0)):
|
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:
|
Arguments:
|
||||||
entry -- the entry for the image to resize
|
entry -- the entry for the image to resize
|
||||||
|
@ -32,6 +32,7 @@ USEFUL_TAGS = [
|
|||||||
'EXIF UserComment',
|
'EXIF UserComment',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def exif_image_needs_rotation(exif_tags):
|
def exif_image_needs_rotation(exif_tags):
|
||||||
"""
|
"""
|
||||||
Returns True if EXIF orientation requires rotation
|
Returns True if EXIF orientation requires rotation
|
||||||
@ -39,6 +40,7 @@ def exif_image_needs_rotation(exif_tags):
|
|||||||
return 'Image Orientation' in exif_tags \
|
return 'Image Orientation' in exif_tags \
|
||||||
and exif_tags['Image Orientation'].values[0] != 1
|
and exif_tags['Image Orientation'].values[0] != 1
|
||||||
|
|
||||||
|
|
||||||
def exif_fix_image_orientation(im, exif_tags):
|
def exif_fix_image_orientation(im, exif_tags):
|
||||||
"""
|
"""
|
||||||
Translate any EXIF orientation to raw orientation
|
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
|
- REDUCES IMAGE QUALITY by recompressig it
|
||||||
|
|
||||||
Pros:
|
Pros:
|
||||||
- Cures my neck pain
|
- Prevents neck pain
|
||||||
"""
|
"""
|
||||||
# Rotate image
|
# Rotate image
|
||||||
if 'Image Orientation' in exif_tags:
|
if 'Image Orientation' in exif_tags:
|
||||||
@ -62,6 +64,7 @@ def exif_fix_image_orientation(im, exif_tags):
|
|||||||
|
|
||||||
return im
|
return im
|
||||||
|
|
||||||
|
|
||||||
def extract_exif(filename):
|
def extract_exif(filename):
|
||||||
"""
|
"""
|
||||||
Returns EXIF tags found in file at ``filename``
|
Returns EXIF tags found in file at ``filename``
|
||||||
@ -76,6 +79,7 @@ def extract_exif(filename):
|
|||||||
|
|
||||||
return exif_tags
|
return exif_tags
|
||||||
|
|
||||||
|
|
||||||
def clean_exif(exif):
|
def clean_exif(exif):
|
||||||
'''
|
'''
|
||||||
Clean the result from anything the database cannot handle
|
Clean the result from anything the database cannot handle
|
||||||
@ -96,6 +100,7 @@ def clean_exif(exif):
|
|||||||
|
|
||||||
return clean_exif
|
return clean_exif
|
||||||
|
|
||||||
|
|
||||||
def _ifd_tag_to_dict(tag):
|
def _ifd_tag_to_dict(tag):
|
||||||
data = {
|
data = {
|
||||||
'printable': tag.printable,
|
'printable': tag.printable,
|
||||||
@ -117,9 +122,11 @@ def _ifd_tag_to_dict(tag):
|
|||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
def _ratio_to_list(ratio):
|
def _ratio_to_list(ratio):
|
||||||
return [ratio.num, ratio.den]
|
return [ratio.num, ratio.den]
|
||||||
|
|
||||||
|
|
||||||
def get_useful(tags):
|
def get_useful(tags):
|
||||||
useful = {}
|
useful = {}
|
||||||
for key, tag in tags.items():
|
for key, tag in tags.items():
|
||||||
@ -150,6 +157,10 @@ def get_gps_data(tags):
|
|||||||
+ (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))
|
+ (float(v[2].num) / float(v[2].den) / (60 * 60))
|
||||||
)(dat.values)
|
)(dat.values)
|
||||||
|
|
||||||
|
if tags['GPS GPSLongitudeRef'].values == 'W':
|
||||||
|
gps_data['longitude'] /= -1
|
||||||
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user