summaryrefslogtreecommitdiffstats
path: root/macrofusion.py
diff options
context:
space:
mode:
Diffstat (limited to 'macrofusion.py')
-rwxr-xr-xmacrofusion.py57
1 files changed, 39 insertions, 18 deletions
diff --git a/macrofusion.py b/macrofusion.py
index be59564..e555edd 100755
--- a/macrofusion.py
+++ b/macrofusion.py
@@ -18,6 +18,7 @@ try:
import operator
import cairo
import random
+ import pyexiv2
except:
print('An error occured. Python or one of its sub modules is absent...\nIt would be wise to check your python installation.')
sys.exit(1)
@@ -44,7 +45,7 @@ global session_options_bak
session_options_bak=[]
APP = 'MacroFusion'
-__VERSION__='0.7.2'
+__VERSION__='0.7.3'
__LICENSE__='GPL'
__COPYRIGHT__='Dariusz Duma'
__WEBSITE__='http://sourceforge.net/p/macrofusion'
@@ -90,9 +91,13 @@ def toggled_cb(cell, path, user_data):
def creer_miniature(chemin,taille):
outfile=donnees.previs_dossier + '/' + os.path.split(chemin)[1]
try:
- im = Image.open(chemin)
- im.thumbnail(taille)
- im.save(outfile, "JPEG")
+ im = gtk.gdk.pixbuf_new_from_file_at_size(chemin, taille[0], taille[1])
+# pb = gtk.gdk.pixbuf_new_from_file(chemin)
+# im = Interface.pixbuf2Image(Interface(),pb)
+# im = Image.open(chemin)
+# im.thumbnail(taille)
+# im.save(outfile, "JPEG")
+ im.save(outfile, "jpeg", {"quality":"98"})
except IOError:
print _("Generating %s thumbnail failed.") % chemin
return outfile
@@ -545,18 +550,28 @@ class Interface:
tags={}
exifinfo=None
try:
- im = Image.open(fichier)
- if hasattr( im, '_getexif' ):
- exifinfo = im._getexif()
- if exifinfo != None:
- for tag, value in exifinfo.items():
- decoded = TAGS.get(tag, tag)
- tags[decoded] = value
- if tags.get('Model'): tags2=(_("<b>Model:</b> ") + str(tags['Model']) + "\n")
- if tags.get('DateTimeOriginal'): tags2+=(_("<b>Date:</b> ") + str(tags['DateTimeOriginal']) + "\n")
- if tags.get('FocalLength'): tags2+=(_("<b>Focal length:</b> ") + str(int(int(tags['FocalLength'][0])/int(tags['FocalLength'][1]))) + "mm \n")
- if tags.get('FNumber'): tags2+=(_("<b>Aperture:</b> F/") + str(float(float(tags['FNumber'][0])/float(tags['FNumber'][1]))) + "\n")
- if tags.get('ExposureTime'): tags2+=(_("<b>Exposure Time:</b> ") + str(str(tags['ExposureTime'][0]/10) + "/" + str(tags['ExposureTime'][1]/10) + " s. \n"))
+ # im = Image.open(fichier)
+ im = pyexiv2.ImageMetadata(fichier)
+ im.read()
+
+# if hasattr( im, '_getexif' ):
+# exifinfo = im._getexif()
+# if exifinfo != None:
+# for tag, value in exifinfo.items():
+# decoded = TAGS.get(tag, tag)
+# tags[decoded] = value
+ tags_keys = im.exif_keys
+ if tags_keys != '':
+ if 'Exif.Image.Model' in tags_keys:
+ tags2=(_("<b>Model:</b> ") + str(im['Exif.Image.Model'].value) + "\n")
+ if 'Exif.Image.DateTimeOriginal' in tags_keys:
+ tags2+=(_("<b>Date:</b> ") + str(im['Exif.Image.DateTimeOriginal'].value) + "\n")
+ if 'Exif.Photo.FocalLength' in tags_keys:
+ tags2+=(_("<b>Focal length:</b> ") + str(int(im['Exif.Photo.FocalLength'].value)) + "mm \n")
+ if 'Exif.Photo.FNumber' in tags_keys:
+ tags2+=(_("<b>Aperture:</b> F/") + str(im['Exif.Photo.FNumber'].value) + "\n")
+ if 'Exif.Photo.ExposureTime' in tags_keys:
+ tags2+=(_("<b>Exposure Time:</b> ") + str(im['Exif.Photo.ExposureTime'].value) + " s. \n")
except IOError:
print "failed to identify", file
return tags2
@@ -616,7 +631,11 @@ class Interface:
# gtk.accel_map_save(self.config_dir + '/accel_map')
return
-
+
+ def pixbuf2Image(self, pb):
+ width,height = pb.get_width(),pb.get_height()
+ return Image.fromstring("RGB",(width,height),pb.get_pixels() )
+
def put_files_to_the_list(self, fichiers):
self.fichiers=fichiers
@@ -624,7 +643,9 @@ class Interface:
self.badfiles=[]
for fichier in self.fichiers:
if re.search('\\.jpg$|\\.jpeg$|\\.tiff$|\\.tif$', fichier, flags=re.IGNORECASE):
- im = Image.open(fichier)
+ pb = gtk.gdk.pixbuf_new_from_file(fichier)
+ im = self.pixbuf2Image(pb)
+# im.save("welldone.jpg", "JPEG",quality=80)
self.size=im.size
self.tags2 = Gui.get_exif(fichier)
if not self.tags2: