NaturalGIS / naturalgis_geotag_and_import_photos

A QGIS plugin to tag and geo-tag photos (and import them as point layer)
GNU General Public License v2.0
9 stars 4 forks source link

Problem with custom tags while importing #3

Open gioman opened 8 years ago

gioman commented 8 years ago

Hi i have images i beforehand entered "normal" tags like lat lon, but also custom tags defined through a config file. I do this process through an excel vba + exiftool-batch stuff, and exiftool reads and writes those values without any complaints as often as i like.

Those images seem to cause problems with the plugin though. Setting the input directory to a dir with such an image gives an error:

Fehler bei der Ausführung von Python-Code:

Traceback (most recent call last):
  File "C:/Users/vogelbe/.qgis//python/plugins\geotagphotos\importphotosdialog.py", line 86, in     selectPhotosDir
    self.loadTags( dirName )
  File "C:/Users/vogelbe/.qgis//python/plugins\geotagphotos\importphotosdialog.py", line 127, in loadTags
    md = et.get_metadata( os.path.join( root, f ) )
  File "C:/Users/vogelbe/.qgis//python/plugins\geotagphotos\exiftool.py", line 255, in get_metadata
return self.execute_json(filename)[0]
  File "C:/Users/vogelbe/.qgis//python/plugins\geotagphotos\exiftool.py", line 239, in execute_json
return json.loads(self.execute(b"-j", *params).decode("utf-8"))
  File "C:\OSGeo4W\apps\Python27\lib\encodings\utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xf7 in position 12620: invalid start byte

Python-Version:
2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)]

QGIS-Version:
1.8.0-Lisboa Lisboa, f440b60@

Python-Pfad: ['C:/OSGeo4W/apps/qgis/./python', 'C:/Users/vogelbe/.qgis//python', 'C:/Users/vogelbe/.qgis//python/plugins', 'C:/OSGeo4W/apps/qgis/./python/plugins', 'C:\\Program Files (x86)\\ArcGIS\\bin', 'C:\\OSGeo4W\\bin\\python27.zip', 'C:\\OSGeo4W\\apps\\Python27\\DLLs', 'C:\\OSGeo4W\\apps\\Python27\\lib', 'C:\\OSGeo4W\\apps\\Python27\\lib\\plat-win', 'C:\\OSGeo4W\\apps\\Python27\\lib\\lib-tk', 'C:\\OSGeo4W\\apps\\qgis\\bin', 'C:\\OSGeo4W\\apps\\Python27', 'C:\\OSGeo4W\\apps\\Python27\\lib\\site-packages', 'C:\\OSGeo4W\\apps\\Python27\\lib\\site-packages\\PIL', 'C:\\OSGeo4W\\apps\\Python27\\lib\\site-packages\\win32', 'C:\\OSGeo4W\\apps\\Python27\\lib\\site-packages\\win32\\lib', 'C:\\OSGeo4W\\apps\\Python27\\lib\\site-packages\\Pythonwin', 'C:\\OSGeo4W\\apps\\Python27\\lib\\site-packages\\wx-2.8-msw-unicode', 'C:\\OSGeo4W\\apps\\qgis\\python\\plugins\\fTools\\tools']

The mouse pointer is busy all the time and the dialog stays open but is the background. No attributes are shown, not even the normal exif-tags. When i in addition add the path to the .config, i get this error.

Fehler bei der Ausführung von Python-Code:

Traceback (most recent call last):
  File "C:/Users/vogelbe/.qgis//python/plugins\geotagphotos\importphotosdialog.py", line 168, in selectConfigFile
    self.loadTags( self.lePhotosPath.text() )
  File "C:/Users/vogelbe/.qgis//python/plugins\geotagphotos\importphotosdialog.py", line 127, in loadTags
    md = et.get_metadata( os.path.join( root, f ) )
  File "C:/Users/vogelbe/.qgis//python/plugins\geotagphotos\exiftool.py", line 255, in get_metadata
return self.execute_json(filename)[0]
  File "C:/Users/vogelbe/.qgis//python/plugins\geotagphotos\exiftool.py", line 239, in execute_json
return json.loads(self.execute(b"-j", *params).decode("utf-8"))
  File "C:\OSGeo4W\apps\Python27\lib\encodings\utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xf7 in position 12620: invalid start byte

Python-Version:
2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)]

It is possible to complete the task and create a shapefile with the proper coordinates, but the attribute list only contains filepath and filename.

After closing the dialog, the mouse pointer is still indicating busyness until i restart Qgis completely.

Config file:

# exiftool config file

%Image::ExifTool::UserDefined = (
    'Image::ExifTool::XMP::Main' => {
        ivl => {
            SubDirectory => {
                TagTable => 'Image::ExifTool::UserDefined::ivl',
            },
        },

    },
);

# This is a basic example of the definition for a new XMP namespace.
# This table is referenced through a SubDirectory tag definition
# in the %Image::ExifTool::UserDefined definition above.
# The namespace prefix for these tags is 'xxx', which corresponds to
# an ExifTool family 1 group name of 'XMP-xxx'.
%Image::ExifTool::UserDefined::ivl = (
    %xmpTableDefaults,
    GROUPS => { 0 => 'XMP', 1 => 'XMP-ivl', 2 => 'Image' },
    NAMESPACE => { 'ivl' => 'http://www.communicatingastronomy.org/ivl1.0/' },
    WRITABLE => 'string',

    'Plotnummer' => {},#AM00200M
    'Unterplot' => {},#AM00223M
    'DateiNeu' =>{},#AM00200M_F1_20100911
    'DateiOrig' => {},#DSC001.jpg
    'DateiDatum' => {},#20100911_1614
    'Fotonummer' => {},#00, 01, F1
    'Text' => { Writable => 'lang-alt' },#-de deutsch oder englisch
    'Datum' => {},#11.09.2011 16:15
    'TextDatum' => {},#11.09.2011
    'Gruppe' => {},#AM
    'Label' => {},#Entweder Fotonummer oder Unterplot
    'Label_X' => {},#Label X-Versatz
    'Label_Y' => {}, #Label-Y-Versatz
);

#------------------------------------------------------------------------------
1; #end