summaryrefslogtreecommitdiffstats
path: root/macrofusion.py
diff options
context:
space:
mode:
Diffstat (limited to 'macrofusion.py')
-rwxr-xr-xmacrofusion.py98
1 files changed, 84 insertions, 14 deletions
diff --git a/macrofusion.py b/macrofusion.py
index c7828c4..2d6e264 100755
--- a/macrofusion.py
+++ b/macrofusion.py
@@ -21,7 +21,8 @@ except:
sys.exit(1)
try:
- import Image
+ import Image
+ from PIL.ExifTags import TAGS
except:
print('Python Imaging Library is missing.')
@@ -42,7 +43,7 @@ session_options_bak=[]
APP = 'MacroFusion'
-if os.path.exists('/usr/share/mfusion/ui/DOFuseInterface.glade') \
+if os.path.exists('/usr/share/mfusion/ui/DOFuseInterface2.glade') \
and os.path.exists('/usr/share/mfusion/ui/Progress.glade') \
and os.path.exists('/usr/share/pixmaps/macrofusion/logoMF.png') \
and os.path.exists('/usr/share/pixmaps/macrofusion/logoSplash.png'):
@@ -50,7 +51,7 @@ if os.path.exists('/usr/share/mfusion/ui/DOFuseInterface.glade') \
DIR = '/usr/share/locale/'
IMG = '/usr/share/pixmaps/macrofusion/'
UI = '/usr/share/mfusion/ui/'
-elif os.path.exists(sys.path[0] + "/ui/DOFuseInterface.glade"):
+elif os.path.exists(sys.path[0] + "/ui/DOFuseInterface2.glade"):
# print ("Local run!")
DIR = sys.path[0] + '/locale/'
IMG = sys.path[0] + '/images/'
@@ -146,7 +147,7 @@ class Interface:
#Set the Glade file
- self.gui=gtk.glade.XML(fname=UI + "DOFuseInterface.glade", domain=APP)
+ self.gui=gtk.glade.XML(fname=UI + "DOFuseInterface2.glade", domain=APP)
#Dans la foulee on chope la fenetre principale, ca sert a rien c'est pour
@@ -160,7 +161,7 @@ class Interface:
self.buttonenleverfichier = self.gui.get_widget("buttonenleverfichier")
self.statusbar = self.gui.get_widget("status1")
self.statusbar.push(1, _("CPU Cores: %s") % self.cpus)
-
+
self.hscaleexp = self.gui.get_widget("hscaleexp")
self.ajus_exp = gtk.Adjustment(value=1, lower=0, upper=1, step_incr=0.1, page_incr=0.1, page_size=0)
self.hscaleexp.set_adjustment(self.ajus_exp)
@@ -257,6 +258,8 @@ class Interface:
self.checkbutton_a5_shift = self.gui.get_widget("checkbutton_a5_shift")
self.checkbutton_a5_field = self.gui.get_widget("checkbutton_a5_field")
+ self.entryedit_field = self.gui.get_widget("entry_editor")
+
self.combobox_desatmet.set_active(0)
self.combtiff.set_active(0)
@@ -306,7 +309,11 @@ class Interface:
self.combtiff.set_active(self.conf.getint('prefs', 'tiffcomp'))
if self.conf.has_option('prefs', 'exif'):
self.checkbuttonexif.set_active(self.conf.getboolean('prefs', 'exif'))
-
+ if self.conf.has_option('prefs', 'editor'):
+ self.entryedit_field.set_text(self.conf.get('prefs', 'editor'))
+ else:
+ self.entryedit_field.set_text("gimp")
+
#On relie les signaux (cliques sur boutons, cochage des cases, ...) aux fonctions appropriées
dic = { "on_mainwindow_destroy" : self.exit_app,
"on_buttonannuler_clicked" : self.exit_app,
@@ -323,11 +330,15 @@ class Interface:
"on_buttoneditw_clicked" : self.sendto,
"on_buttonbeforeafter_pressed" : self.baswitch,
"on_buttonbeforeafter_released" : self.baswitch,
+ "on_entry_editor_activate" : self.check_editor,
+ # "on_entry_editor_focus_out_event" : self.check_editor,
"on_imagemenuitem10_activate" : self.apropos
}
#Auto-connection des signaux
+ # self.entryedit_field.connect("activate", self.apropos)
+ #self.entryedit_field.connect("focus_out_event", self.apropos)
self.gui.signal_autoconnect(dic)
-
+
#initialisation de la liste d'images a fusionner
self.inittreeview()
@@ -341,6 +352,13 @@ class Interface:
self.cleanup()
sys.exit(0)
+ def check_editor(self, action):
+ if not donnees.check_install(self.entryedit_field.get_text()):
+ Gui.messageinthebottle(_("No such application!\n\n Cannot find " + self.entryedit_field.get_text() + _(".\n\n Revert to default value.")))
+ self.entryedit_field.set_text("gimp")
+ return False
+ return True
+
def cleanup(self):
# os.remove(donnees.enfuse_dossier + "/session.sav")
for self.files in os.walk(donnees.previs_dossier):
@@ -349,8 +367,9 @@ class Interface:
def inittreeview(self):
"""initialisation de la liste d'images a importer"""
- self.liststoreimport = gtk.ListStore(bool, str, str) #création de la listestore qui contiendra les noms d'images
+ self.liststoreimport = gtk.ListStore(bool, str, str, gtk.gdk.Pixbuf, str) #création de la listestore qui contiendra les noms d'images
self.listeimages.set_model(self.liststoreimport) #on donne la liststore au l'afficheur treeview
+ self.listeimages.set_property('tooltip-column', 4)
self.colonneselect = gtk.TreeViewColumn('') #Premiere colonne :
self.listeimages.append_column(self.colonneselect) #on l'ajoute au TreeView
@@ -363,7 +382,17 @@ class Interface:
self.cell = gtk.CellRendererText() #Ce sera des cellules de texte
self.colonneimages.pack_start(self.cell, True) #que l'on met dans la colonne
self.colonneimages.add_attribute(self.cell, 'text', 1) #et on specifie que c'est du texte simple
+
+ self.colonneimages2 = gtk.TreeViewColumn(_("Thumbnail")) #deuxieme colonne, titre 'Image'
+ self.listeimages.append_column(self.colonneimages2) #on rajoute la colonne dans le treeview
+ self.cell2 = gtk.CellRendererPixbuf() #Ce sera des cellules de texte
+ self.colonneimages2.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
+ self.colonneimages2.pack_start(self.cell2, True) #que l'on met dans la colonne
+ self.colonneimages2.add_attribute(self.cell2, 'pixbuf', 3)
+ self.cell2.set_property('visible', 1)
+
+ self.listeimages.set_rules_hint(True)
self.select.connect("toggled", toggled_cb, (self.liststoreimport, 0)) #Pour que les boutons de selection marchent
@@ -498,6 +527,8 @@ class Interface:
def sendto(self, widget):
self.name=(donnees.previs_dossier + "/sendto.tif")
+ if not self.check_editor(0):
+ return
if self.enroute(self.name) == -1:
self.messageinthebottle(_("No preview, no output, no edit.\n\n Game Over."))
return
@@ -552,7 +583,8 @@ class Interface:
conf.set('prefs', 'jpegcompr', int(self.hscalecomprjpeg.get_value()))
conf.set('prefs', 'tiffcomp', str(self.combtiff.get_active()))
conf.set('prefs', 'exif', str(self.checkbuttonexif.get_active()))
-
+ conf.set('prefs', 'editor', self.entryedit_field.get_text())
+
if not os.path.exists(donnees.enfuse_dossier):
os.makedirs(donnees.enfuse_dossier)
conf.write(file(donnees.enfuse_dossier + '/mfusion.cfg', 'w'))
@@ -561,7 +593,9 @@ class Interface:
# gtk.accel_map_save(self.config_dir + '/accel_map')
return
+
+
####################################################################
###########Classe pour choisir les images a fusionner###############
####################################################################
@@ -594,9 +628,30 @@ class Fenetre_Ouvrir:
if(self.fenetre_ouvrir.run() == gtk.RESPONSE_OK):
self.fichiers = self.fenetre_ouvrir.get_filenames()
+ self.tags2=''
donnees.default_file=self.fichiers[0]
for fichier in self.fichiers:
- self.liststoreimport.append([1,os.path.basename(fichier),fichier])
+ try:
+ im = Image.open(fichier)
+ self.tags={}
+ self.size=im.size
+ if hasattr( im, '_getexif' ):
+ exifinfo = im._getexif()
+ if exifinfo != None:
+ for tag, value in exifinfo.items():
+ decoded = TAGS.get(tag, tag)
+ self.tags[decoded] = value
+ self.tags2=(_("<b>Model:</b> ") + str(self.tags['Model']) + "\n")
+ self.tags2+=(_("<b>Date:</b> ") + str(self.tags['DateTimeOriginal']) + "\n")
+ self.tags2+=(_("<b>Focal length:</b> ") + str(int(int(self.tags['FocalLength'][0])/int(self.tags['FocalLength'][1]))) + "mm \n")
+ self.tags2+=(_("<b>Aperture:</b> F/") + str(float(float(self.tags['FNumber'][0])/float(self.tags['FNumber'][1]))) + "\n")
+ self.tags2+=(_("<b>Exposure Time:</b> ") + str(str(self.tags['ExposureTime'][0]/10) + "/" + str(self.tags['ExposureTime'][1]/10) + " s. \n"))
+ except IOError:
+ print "failed to identify", file
+
+ self.tooltip=("\n" + _("<b>Filename:</b> ") + os.path.basename(fichier) + "\n"+_("<b>Resolution:</b> ") + str(str(self.size[0]) + "x" + str(self.size[1])) + "\n" + self.tags2)
+ self.liststoreimport.append([1,os.path.basename(fichier), fichier, gtk.gdk.pixbuf_new_from_file_at_size(fichier, 128, 128), self.tooltip])
+
donnees.default_folder=self.fenetre_ouvrir.get_current_folder()
self.fenetre_ouvrir.destroy()
@@ -606,7 +661,21 @@ class Fenetre_Ouvrir:
return self.liststoreimport
else:
return None
-
+
+ def get_exif_data(fname):
+ """Get embedded EXIF data from image file."""
+ ret = {}
+ try:
+ img = Image.open(fname)
+ if hasattr( img, '_getexif' ):
+ exifinfo = img._getexif()
+ if exifinfo != None:
+ for tag, value in exifinfo.items():
+ decoded = TAGS.get(tag, tag)
+ ret[decoded] = value
+ except IOError:
+ print 'IOERROR ' + fname
+ return ret
#####################################################################
#########Classe pour la fenetre pour choisir le fichier final########
@@ -677,11 +746,12 @@ class Thread_Preview(threading.Thread):
preview_process.wait()
session_options_bak=self.options_align
session_images_bak=images_a_align
+ Gui.statusbar.pop(15)
Gui.statusbar.push(15, _(":: Fusion photos..."))
command=[Gui.enfuser, "-o", donnees.previs_dossier + "/" + "preview.jpg"] + self.options + images_a_fusionner
preview_process=subprocess.Popen(command, stdout=subprocess.PIPE)
preview_process.wait()
-
+ Gui.statusbar.pop(15)
#######################################################################
@@ -745,7 +815,7 @@ class Thread_Fusion(threading.Thread):
exif_copy = subprocess.Popen(["exiftool", "-tagsFromFile", Gui.liste_images[0], "-overwrite_original", Gui.name])
exif_copy.wait()
if len(self.issend) > 0:
- subprocess.Popen(['gimp', self.issend], stdout=subprocess.PIPE)
+ subprocess.Popen([Gui.entryedit_field.get_text(), self.issend], stdout=subprocess.PIPE)
########################################
#### Classe de la fenêtre a propos ####
@@ -759,7 +829,7 @@ class AproposFen:
self.aboutdialog.set_name("MacroFusion")
self.aboutdialog.set_modal(True)
self.aboutdialog.set_position(gtk.WIN_POS_CENTER)
- self.aboutdialog.set_version('0.5')
+ self.aboutdialog.set_version('0.6')
self.aboutdialog.set_comments('A GTK Gui for the excellent Enfuse.\n Based on EnfuseGui by Chez Gholyo.\n\n(c) 2011 Dariusz Duma <dhor@toxic.net.pl>')
self.pixbuf=gtk.gdk.pixbuf_new_from_file(IMG + "logoMF.png")
self.aboutdialog.set_logo(self.pixbuf)