The exif tags option will only be displayed if they have the pyexiv2 library installed. Great error prevention.
svn: r13584
This commit is contained in:
parent
ff073515be
commit
4a98fd23d6
@ -304,7 +304,10 @@ class BasePage(object):
|
|||||||
self.linkhome = report.options['linkhome']
|
self.linkhome = report.options['linkhome']
|
||||||
self.create_media = report.options['gallery']
|
self.create_media = report.options['gallery']
|
||||||
self.inc_events = report.options['inc_events']
|
self.inc_events = report.options['inc_events']
|
||||||
self.exiftagsopt = report.options['exiftagsopt']
|
|
||||||
|
# only show option if the pyexiv2 library is available on local system
|
||||||
|
if pyexiftaglib:
|
||||||
|
self.exiftagsopt = report.options['exiftagsopt']
|
||||||
|
|
||||||
def get_birth_date(self, db, person):
|
def get_birth_date(self, db, person):
|
||||||
""" Will return a date object for a person's birthdate """
|
""" Will return a date object for a person's birthdate """
|
||||||
@ -2603,36 +2606,35 @@ class MediaPage(BasePage):
|
|||||||
table += trow
|
table += trow
|
||||||
|
|
||||||
# display image Exif tags/ keys if any?
|
# display image Exif tags/ keys if any?
|
||||||
if ((pyexiftaglib and self.exiftagsopt) and mime_type.startswith("image/")):
|
if pyexiftaglib:
|
||||||
"""
|
if self.exiftagsopt and mime_type.startswith("image/"):
|
||||||
# Determine if the python exif lib is installed on the system?
|
|
||||||
# yes, then use it and determine if the photo has anything written inside of it?
|
|
||||||
"""
|
|
||||||
|
|
||||||
image = pyexiv2.Image("%s" % Utils.media_path_full(db, media.get_path()) )
|
# if the pyexiv2 library is installed, then show if the option has been set,
|
||||||
image.readMetadata()
|
# yes, then use it and determine if the image has anything written inside of it?
|
||||||
|
image = pyexiv2.Image("%s" % Utils.media_path_full(db, media.get_path()) )
|
||||||
|
image.readMetadata()
|
||||||
|
|
||||||
# exif data does exists
|
# exif data does exists
|
||||||
if len(image.exifKeys() ):
|
if len(image.exifKeys() ):
|
||||||
|
|
||||||
# initialize the dictionary for holding the image exif tags
|
# initialize the dictionary for holding the image exif tags
|
||||||
imagetags = []
|
imagetags = []
|
||||||
|
|
||||||
# add exif title header
|
# add exif title header
|
||||||
mediadetail += Html("h4", _("Image Exif Tags/ Keys"), inline = True)
|
mediadetail += Html("h4", _("Image Exif Tags/ Keys"), inline = True)
|
||||||
|
|
||||||
# begin exif table
|
# begin exif table
|
||||||
with Html("table", class_ = "exifdata") as table:
|
with Html("table", class_ = "exifdata") as table:
|
||||||
mediadetail += table
|
mediadetail += table
|
||||||
|
|
||||||
for keytag in image.exifKeys():
|
for keytag in image.exifKeys():
|
||||||
if keytag not in imagetags:
|
if keytag not in imagetags:
|
||||||
trow = Html("tr") + (
|
trow = Html("tr") + (
|
||||||
Html("td", keytag, class_ = "ColumnAttribute"),
|
Html("td", keytag, class_ = "ColumnAttribute"),
|
||||||
Html("td", image[keytag], class_ = "ColumnValue")
|
Html("td", image[keytag], class_ = "ColumnValue")
|
||||||
)
|
)
|
||||||
table += trow
|
table += trow
|
||||||
imagetags.append(keytag)
|
imagetags.append(keytag)
|
||||||
|
|
||||||
##################### End of Exif Tags #####################################################
|
##################### End of Exif Tags #####################################################
|
||||||
|
|
||||||
@ -4837,8 +4839,9 @@ class NavWebReport(Report):
|
|||||||
self.inc_contact = self.options['contactnote'] or \
|
self.inc_contact = self.options['contactnote'] or \
|
||||||
self.options['contactimg']
|
self.options['contactimg']
|
||||||
|
|
||||||
# exif tags option
|
# only show option if the pyexiv2 library is available on local system
|
||||||
self.exiftagsopt = self.options["exiftagsopt"]
|
if pyexiftaglib:
|
||||||
|
self.exiftagsopt = self.options["exiftagsopt"]
|
||||||
|
|
||||||
# name format option
|
# name format option
|
||||||
self.name_format = self.options['name_format']
|
self.name_format = self.options['name_format']
|
||||||
@ -5739,11 +5742,13 @@ class NavWebOptions(MenuReportOptions):
|
|||||||
menu.add_option(category_name, 'gallery', self.__gallery)
|
menu.add_option(category_name, 'gallery', self.__gallery)
|
||||||
self.__gallery.connect('value-changed', self.__gallery_changed)
|
self.__gallery.connect('value-changed', self.__gallery_changed)
|
||||||
|
|
||||||
self.__exiftags = BooleanOption(_("Whether to add exif tags to the media page or not?"), False)
|
# only show option if the pyexiv2 library is available on local system
|
||||||
self.__exiftags.set_help(_("Do you want to add the exif data tags to the page? You will"
|
if pyexiftaglib:
|
||||||
" need to have the pyexiv2 library installed on your system."
|
self.__exiftags = BooleanOption(_("Whether to add exif tags to the media page or not?"), False)
|
||||||
"It can be downloaded from here: http://www.exiv2.org/ ."))
|
self.__exiftags.set_help(_("Do you want to add the exif data tags to the page? You will"
|
||||||
menu.add_option(category_name, "exiftagsopt", self.__exiftags)
|
" need to have the pyexiv2 library installed on your system."
|
||||||
|
"It can be downloaded from here: http://www.exiv2.org/ ."))
|
||||||
|
menu.add_option(category_name, "exiftagsopt", self.__exiftags)
|
||||||
|
|
||||||
self.__maxinitialimagewidth = NumberOption(_("Max width of initial image"),
|
self.__maxinitialimagewidth = NumberOption(_("Max width of initial image"),
|
||||||
_DEFAULT_MAX_IMG_WIDTH, 0, 2000)
|
_DEFAULT_MAX_IMG_WIDTH, 0, 2000)
|
||||||
@ -5945,11 +5950,17 @@ class NavWebOptions(MenuReportOptions):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
if self.__gallery.get_value() == False:
|
if self.__gallery.get_value() == False:
|
||||||
self.__exiftags.set_available(False)
|
|
||||||
|
# only show option if the pyexiv2 library is available on local system
|
||||||
|
if pyexiftaglib:
|
||||||
|
self.__exiftags.set_available(False)
|
||||||
self.__maxinitialimagewidth.set_available(False)
|
self.__maxinitialimagewidth.set_available(False)
|
||||||
self.__maxinitialimageheight.set_available(False)
|
self.__maxinitialimageheight.set_available(False)
|
||||||
else:
|
else:
|
||||||
self.__exiftags.set_available(True)
|
|
||||||
|
# only show option if the pyexiv2 library is available on local system
|
||||||
|
if pyexiftaglib:
|
||||||
|
self.__exiftags.set_available(True)
|
||||||
self.__maxinitialimagewidth.set_available(True)
|
self.__maxinitialimagewidth.set_available(True)
|
||||||
self.__maxinitialimageheight.set_available(True)
|
self.__maxinitialimageheight.set_available(True)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user