Added convertDialog, fixed several errors, and removed the delete converted image function as it was not working anyways.
svn: r17326
This commit is contained in:
parent
d76db89d16
commit
e1e8fa21d9
@ -104,35 +104,28 @@ if (software_version and (software_version < Min_VERSION)):
|
|||||||
# The programs are ImageMagick, and jhead
|
# The programs are ImageMagick, and jhead
|
||||||
# * ImageMagick -- Convert and Delete all Exif metadata...
|
# * ImageMagick -- Convert and Delete all Exif metadata...
|
||||||
# * jhead -- re-initialize a jpeg image...
|
# * jhead -- re-initialize a jpeg image...
|
||||||
# * del -- delete the image after converting to Jpeg...
|
|
||||||
#********************************************************************
|
#********************************************************************
|
||||||
system_platform = os.sys.platform
|
system_platform = os.sys.platform
|
||||||
# Windows 32bit systems
|
# Windows 32bit systems
|
||||||
if system_platform == "win32":
|
if system_platform == "win32":
|
||||||
_MAGICK_FOUND = Utils.search_for("convert.exe")
|
_MAGICK_FOUND = Utils.search_for("convert.exe")
|
||||||
_JHEAD_FOUND = Utils.search_for("jhead.exe")
|
_JHEAD_FOUND = Utils.search_for("jhead.exe")
|
||||||
_DEL_FOUND = Utils.search_for("del.exe")
|
|
||||||
__del_command = "del.exe"
|
|
||||||
|
|
||||||
# all Linux systems
|
# all Linux systems
|
||||||
elif system_platform == "Linux2":
|
elif system_platform == "Linux2":
|
||||||
_MAGICK_FOUND = Utils.search_for("convert")
|
_MAGICK_FOUND = Utils.search_for("convert")
|
||||||
_JHEAD_FOUND = Utils.search_for("jhead")
|
_JHEAD_FOUND = Utils.search_for("jhead")
|
||||||
_DEL_FOUND = Utils.search_for("rm")
|
|
||||||
__del_command = "rm"
|
|
||||||
|
|
||||||
# Windows 64bit systems
|
# Windows 64bit systems
|
||||||
else:
|
else:
|
||||||
_MAGICK_FOUND = Utils.search_for("convert")
|
_MAGICK_FOUND = Utils.search_for("convert")
|
||||||
_JHEAD_FOUND = Utils.search_for("jhead")
|
_JHEAD_FOUND = Utils.search_for("jhead")
|
||||||
_DEL_FOUND = Utils.search_for("del")
|
|
||||||
__del_command = "del"
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# Constants
|
# Constants
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# available image types for exiv2 and pyexiv2
|
# available image types for exiv2 and pyexiv2
|
||||||
# ["jpeg", "jpg", "exv", "tiff", "dng", "nef", "pef", "pgf", "png", "psd", "jp2"]
|
# [".jpeg", ".jpg", ".jfif", ".exv", ".tiff", ".dng", ".nef", ".pef", ".pgf", ".png", ".psd", ".jp2"]
|
||||||
|
|
||||||
# define tooltips for all entries
|
# define tooltips for all entries
|
||||||
_TOOLTIPS = {
|
_TOOLTIPS = {
|
||||||
@ -333,7 +326,7 @@ class EditExifMetadata(Gramplet):
|
|||||||
if _MAGICK_FOUND:
|
if _MAGICK_FOUND:
|
||||||
# Convert button...
|
# Convert button...
|
||||||
ccc_box.add( self.__create_button(
|
ccc_box.add( self.__create_button(
|
||||||
"Convert", False, self.convert2Jpeg, gtk.STOCK_CONVERT, False) )
|
"Convert", False, self.__convert_dialog, gtk.STOCK_CONVERT, False) )
|
||||||
|
|
||||||
for items in [
|
for items in [
|
||||||
|
|
||||||
@ -408,7 +401,7 @@ class EditExifMetadata(Gramplet):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
full_path = Utils.media_path_full(self.dbstate.db, media.get_path() )
|
full_path = Utils.media_path_full(self.dbstate.db, media.get_path() )
|
||||||
if not os.join.isfile(full_path):
|
if not os.path.isfile(full_path):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if LesserVersion: # prior to v0.2.0
|
if LesserVersion: # prior to v0.2.0
|
||||||
@ -545,22 +538,25 @@ class EditExifMetadata(Gramplet):
|
|||||||
|
|
||||||
return button
|
return button
|
||||||
|
|
||||||
|
def __convert_dialog(self, obj):
|
||||||
|
"""
|
||||||
|
Handles the Convert Question Dialog...
|
||||||
|
"""
|
||||||
|
|
||||||
|
QuestionDialog(_("Edit Image Exif metadata"), _("Convert this image to a .jpeg image?"),
|
||||||
|
_("Convert"), self.convert2Jpeg)
|
||||||
|
|
||||||
def __save_dialog(self, obj):
|
def __save_dialog(self, obj):
|
||||||
"""
|
"""
|
||||||
Handles the Save question Dialog...
|
Handles the Save question Dialog...
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.SavedEntries = [self.exif_widgets[widget].get_text() for widget in [
|
QuestionDialog(_("Edit Image Exif Metadata"), _("Save Exif metadata to this image?"),
|
||||||
"Description", "Artist", "Copyright", "DateTime", "Latitude", "Longitude"] ]
|
_("Save"), self.save_metadata)
|
||||||
self.SavedEntries = [entry for entry in self.SavedEntries if entry]
|
|
||||||
if self.SavedEntries:
|
|
||||||
|
|
||||||
QuestionDialog(_("Edit Image Exif Metadata"), _("Save Exif metadata to this image?"),
|
|
||||||
_("Save"), self.save_metadata)
|
|
||||||
|
|
||||||
def __delete_dialog(self, obj):
|
def __delete_dialog(self, obj):
|
||||||
"""
|
"""
|
||||||
Handles the Delete Dialog...
|
Handles the Delete Question Dialog...
|
||||||
"""
|
"""
|
||||||
|
|
||||||
QuestionDialog(_("Edit Image Exif Metadata"), _("WARNING! You are about to completely "
|
QuestionDialog(_("Edit Image Exif Metadata"), _("WARNING! You are about to completely "
|
||||||
@ -852,34 +848,28 @@ class EditExifMetadata(Gramplet):
|
|||||||
else:
|
else:
|
||||||
self.exif_widgets["DateTime"].set_text("")
|
self.exif_widgets["DateTime"].set_text("")
|
||||||
|
|
||||||
def convert2Jpeg(self, obj):
|
def convert2Jpeg(self):
|
||||||
"""
|
"""
|
||||||
Will attempt to convert an image to jpeg if it is not?
|
Will attempt to convert an image to a .jpeg image.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# if ImageMagick's convert is installed...
|
# if ImageMagick's convert is installed...
|
||||||
if _MAGICK_FOUND:
|
if _MAGICK_FOUND:
|
||||||
self.exif_widgets["Message:Area"].set_text(_("Converting image to a jpeg image..."))
|
|
||||||
|
|
||||||
filepath, basename = os.path.split(self.image_path)
|
filepath, basename = os.path.split(self.image_path)
|
||||||
basename, oldext = os.path.splitext(self.image_path)
|
basename, oldext = os.path.splitext(self.image_path)
|
||||||
newextension = ".jpeg"
|
newextension = ".jpeg"
|
||||||
|
|
||||||
change = subprocess.check_call( ["convert", self.image_path,
|
convert = subprocess.check_call( ["convert", self.image_path,
|
||||||
os.path.join(filepath, basename + newextension) ] )
|
os.path.join(filepath, basename + newextension) ] )
|
||||||
|
if str(convert):
|
||||||
|
|
||||||
if str(change):
|
# set Message Area to Convert...
|
||||||
self.disable_button(["Convert"])
|
self.exif_widgets["Message:Area"].set_text(_("Converting image,\n"
|
||||||
|
"You will need to delete the original image file..."))
|
||||||
|
|
||||||
if _DEL_FOUND:
|
# deactivate Convert button...
|
||||||
if _del_command is not "rm":
|
self.deactivate_buttons(["Convert"])
|
||||||
deleted = subprocess.check_call( [_del_command, self.image_path] )
|
|
||||||
else:
|
|
||||||
deleted = subprocess.check_call( [_del_command, "-rf", self.image_path] )
|
|
||||||
|
|
||||||
if str(deleted):
|
|
||||||
self.exif_widgets["Message:Area"].set_text(_("Original image has "
|
|
||||||
"been deleted!"))
|
|
||||||
|
|
||||||
def _set_exif_KeyTag(self, KeyTag, KeyValue):
|
def _set_exif_KeyTag(self, KeyTag, KeyValue):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user