geotag action crash when trying to write the Exif_GPSInfo_GPSAltitudeRef tag

Bug #1354196 reported by Ruben
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
phatch (Ubuntu)
New
Undecided
Unassigned

Bug Description

source package:
**************
phatch-cli

ubuntu release:
**************
Description: Ubuntu 14.04 LTS
Release: 14.04

version:
*******
phatch:
  Instalados: 0.2.7.1-3
  Candidato: 0.2.7.1-3
  Tabla de versión:
 *** 0.2.7.1-3 0
        500 http://es.archive.ubuntu.com/ubuntu/ trusty/universe amd64 Packages
        100 /var/lib/dpkg/status

When trying to assing goetags to photos using a GARMIN GPX file y get this error for every photo (spanish version, sorry) and no geotag is modified:

Error 0:No se puede aplicar la acción Geoetiqueta a la imagen 'photo.JPG' en la carpeta:
/Testing/PhotoFolder

u'Imposible escribir marca "Exif_GPSInfo_GPSAltitudeRef":\nInvalid value for EXIF type [Byte]: [0]'

Action:{'fields': {'GPS Data (gpx)': u'/GPSTrack.gpx',
            'GPS Report (csv)': ' ',
            'Time Shift (seconds)': u'60',
            '__enabled__': 'yes'},
 'label': 'Geotag'}

Traceback (most recent call last):
  File "/usr/share/phatch/phatch/core/api.py", line 614, in apply_action_to_photo
    photo = action.apply(photo, read_only_settings, cache)
  File "/usr/share/phatch/phatch/actions/geotag.py", line 75, in apply
    info[key.replace('.', '_')] = value # writable
  File "/usr/share/phatch/phatch/core/pil.py", line 365, in __setitem__
    % (_('Impossible to write tag "%s"') % tag, message))
KeyError: u'Imposible escribir marca "Exif_GPSInfo_GPSAltitudeRef":\nInvalid value for EXIF type [Byte]: [0]'
*

The problem is that 'Exif_GPSInfo_GPSAltitudeRef' tag uses a byte type value while phatch is trying to write a int type value (eleR):

---------------------------------------------------------
in GPS.py at line 203

    latR = 'N'
    lonR = 'E'
    eleR = 0
    if lat < 0:
        lat = -lat
        latR = 'S'
    if lon < 0:
        lon = -lon
        lonR = 'W'
    sele = "%6.1f" % (ele)
    if ele < 0:
        ele = -ele
        eleR = 1

    slat = "%02d.%02d'" '%02d"%s' % (d(lat), m(lat), s(lat), latR)
    slon = "%02d.%02d'" '%02d"%s' % (d(lon), m(lon), s(lon), lonR)
    if report:
        report.write(",".join([stamp, timestamp, slat, slon, sele, path])\
            + "\n")
    # get Rational number for ele
    # don't know why r(ele) is causing trouble!
    # it might be that the denominator is overflowing 32 bits!
    # and this would also import lat and lon
    rele = pyexiv2.Rational(int(ele * 10.0), 10)
    # create and return the dictionary of tags to be added to the image
    metadata = {}
    metadata['Exif_GPSInfo_GPSAltitude'] = rele
    metadata['Exif_GPSInfo_GPSAltitudeRef'] = eleR:
---------------------------------------------------------

I have solved the problem by transforming eleR to byte with the bytes() constructor:

metadata['Exif_GPSInfo_GPSAltitudeRef'] = bytes(eleR)

Revision history for this message
Ruben (ruben-reguero-otr) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.