Skip to content

Commit

Permalink
Remove dependency to pyexiftool, use GExiv2 instead (seems to work no…
Browse files Browse the repository at this point in the history
…w with inconsistent metadata)
  • Loading branch information
Aerilius committed Jan 30, 2017
1 parent 789d8bd commit 54b7f04
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 1,136 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ implementation could be realized or even included into Eye of Gnome.

## Requirements

- **Exiftool** which can be installed with `sudo apt install libimage-exiftool-perl`

- A recent distribution with Eye of Gnome 3+, **Python3**, Gtk+3, WebKit2 (tested on Ubuntu 16.10)

## Installation
Expand Down
15 changes: 7 additions & 8 deletions eog_panorama/eog_panorama.htm
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,6 @@
var PSV;
document.addEventListener("DOMContentLoaded", function(event) {


// Tell python when the document finished loading.
// While instantiation of WebView is synchronous, loading of html is asynchronous.
// In order to interact from python with the html/javascript, we need to await the document ready event.
// Note: Webkit returns incorrect viewport values (window.innerWidth=0 etc.) still ca. 1s after onload.
callPython('document_ready');


// Initialize the panorama viewer.
PSV = new PhotoSphereViewer({
container: 'photosphere',
Expand Down Expand Up @@ -152,6 +144,13 @@
if (position.y) result.y = position.y * (1 + dy);
return result;
}


// Tell python when the document finished loading.
// While instantiation of WebView is synchronous, loading of html is asynchronous.
// In order to interact from python with the html/javascript, we need to await the document ready event.
// Note: Webkit returns incorrect viewport values (window.innerWidth=0 etc.) still ca. 1s after onload.
callPython('document_ready');
});


Expand Down
59 changes: 26 additions & 33 deletions eog_panorama/eog_panorama.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
from gi.repository import Gtk, GObject, Gio, Eog

# EXIF/XMP metadata
from pyexiftool.exiftool import ExifTool
gi.require_version('GExiv2', '0.10')
from gi.repository import GExiv2

# Webview for WebGL panorama viewer
gi.require_version('WebKit2', '4.0')
Expand Down Expand Up @@ -128,8 +129,8 @@ def on_selection_changed(self, thumb_view):


def use_panorama_viewer(self, filepath):
with ExifTool() as et:
return et.get_tag('XMP:UsePanoramaViewer', filepath)
metadata = GExiv2.Metadata(filepath)
return metadata.get_tag_string('Xmp.GPano.UsePanoramaViewer') == 'True'



Expand All @@ -141,42 +142,34 @@ def get_pano_xmp(self, filepath):
Returns:
a dict containing XMP keys with their values
"""
# Exiv2 is not robust and does not read any GPano XMP tags at all if there exist duplicate tags.
#metadata = GExiv2.Metadata(filepath)
metadata = GExiv2.Metadata(filepath)
# For tags see: http://www.exiv2.org/tags.html
# and http://exiv2.org/tags-xmp-GPano.html
#print(metadata.get_tag_label('Xmp.GPano.UsePanoramaViewer'))
#print(metadata.get_tag_string('Xmp.GPano.UsePanoramaViewer'))
#print(metadata.get_tag_raw('Xmp.GPano.UsePanoramaViewer'))

# Using exiftool instead.
tags_required = {
'XMP:FullPanoWidthPixels': 'full_width',
'XMP:FullPanoHeightPixels': 'full_height',
'XMP:CroppedAreaImageWidthPixels': 'cropped_width',
'XMP:CroppedAreaImageHeightPixels': 'cropped_height',
'XMP:CroppedAreaLeftPixels': 'cropped_x',
'XMP:CroppedAreaTopPixels': 'cropped_y'
'Xmp.GPano.FullPanoWidthPixels': 'full_width',
'Xmp.GPano.FullPanoHeightPixels': 'full_height',
'Xmp.GPano.CroppedAreaImageWidthPixels': 'cropped_width',
'Xmp.GPano.CroppedAreaImageHeightPixels': 'cropped_height',
'Xmp.GPano.CroppedAreaLeftPixels': 'cropped_x',
'Xmp.GPano.CroppedAreaTopPixels': 'cropped_y'
}
tags_optional = {
'XMP:PoseHeadingDegrees': 'pose_heading',
'XMP:InitialHorizontalFOVDegrees': 'initial_h_fov',
'XMP:InitialViewHeadingDegrees': 'initial_heading',
'XMP:InitialViewPitchDegrees': 'initial_pitch',
'XMP:InitialViewRollDegrees': 'initial_roll'
'Xmp.GPano.PoseHeadingDegrees': 'pose_heading',
'Xmp.GPano.InitialHorizontalFOVDegrees': 'initial_h_fov',
'Xmp.GPano.InitialViewHeadingDegrees': 'initial_heading',
'Xmp.GPano.InitialViewPitchDegrees': 'initial_pitch',
'Xmp.GPano.InitialViewRollDegrees': 'initial_roll'
}
with ExifTool() as et:
metadata = et.get_tags(list(tags_required.keys()) + list(tags_optional.keys()), filepath)
result = {}
for (tag, key) in tags_required.items():
if tag in metadata:
result[key] = int(metadata[tag])
else:
raise Exception("Required tag %s is missing, cannot use panorama viewer."%tag)
for (tag, key) in tags_optional.items():
if tag in metadata:
result[key] = int(metadata[tag])
return result
result = {}
for (tag, key) in tags_required.items():
if metadata.has_tag(tag):
result[key] = int(metadata.get_tag_string(tag))
else:
raise Exception("Required tag %s is missing, cannot use panorama viewer."%tag)
for (tag, key) in tags_optional.items():
if metadata.has_tag(tag):
result[key] = int(metadata.get_tag_string(tag))
return result



Expand Down
24 changes: 0 additions & 24 deletions eog_panorama/pyexiftool/COPYING.BSD

This file was deleted.

Loading

0 comments on commit 54b7f04

Please sign in to comment.