summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--exifilm.py36
-rw-r--r--printrecord.py14
2 files changed, 25 insertions, 25 deletions
diff --git a/exifilm.py b/exifilm.py
index 17db62d..2041ec9 100644
--- a/exifilm.py
+++ b/exifilm.py
@@ -68,7 +68,7 @@ PRIVATE_KEYS = [
68 ] 68 ]
69 69
70ISO_RE = re.compile(r'\d\d+') 70ISO_RE = re.compile(r'\d\d+')
71 71
72def to_rational(v): 72def to_rational(v):
73 if '/' in v: 73 if '/' in v:
74 n,d = v.split('/') 74 n,d = v.split('/')
@@ -150,9 +150,9 @@ class ExiFilm(object):
150 self.comments_text = self.xml.get_widget('comments') 150 self.comments_text = self.xml.get_widget('comments')
151 self.comments_buffer = gtk.TextBuffer() 151 self.comments_buffer = gtk.TextBuffer()
152 self.comments_text.set_buffer(self.comments_buffer) 152 self.comments_text.set_buffer(self.comments_buffer)
153 153
154 # Keep the last selected date to provide a sane default 154 # Keep the last selected date to provide a sane default
155 self.lastdate = None 155 self.lastdate = None
156 156
157 dic = { 157 dic = {
158 'on_main_window_destroy': self.window_closed, 158 'on_main_window_destroy': self.window_closed,
@@ -201,36 +201,36 @@ class ExiFilm(object):
201 if i>0: 201 if i>0:
202 self.file_combo.set_active(i-1) 202 self.file_combo.set_active(i-1)
203 return True 203 return True
204 204
205 if data.keyval == gtk.keysyms.Page_Down: 205 if data.keyval == gtk.keysyms.Page_Down:
206 i = self.file_combo.get_active() 206 i = self.file_combo.get_active()
207 if i<len(self.file_store)-1: 207 if i<len(self.file_store)-1:
208 self.file_combo.set_active(i+1) 208 self.file_combo.set_active(i+1)
209 return True 209 return True
210 210
211 def load(self, fn): 211 def load(self, fn):
212 fn = os.path.join(self.directory, fn) 212 fn = os.path.join(self.directory, fn)
213 self.filename = fn 213 self.filename = fn
214 214
215 image = pyexiv2.Image(fn) 215 image = pyexiv2.ImageMetadata(fn)
216 image.readMetadata() 216 image.read()
217 keys = image.exifKeys() 217 keys = image.exif_keys
218 self.image = image 218 self.image = image
219 219
220 def get(key, default=''): 220 def get(key, default=''):
221 if key in keys: 221 if key in keys:
222 return image[key] 222 return image[key].value
223 return default 223 return default
224 224
225 self.date = get('Exif.Photo.DateTimeOriginal', None) 225 self.date = get('Exif.Photo.DateTimeOriginal', None)
226 if self.date: 226 if self.date:
227 self.date_button.set_label(str(self.date.date())) 227 self.date_button.set_label(str(self.date.date()))
228 else: 228 else:
229 self.date_button.set_label('Set') 229 self.date_button.set_label('Set')
230 230
231 self.shutter_entry.set_text(from_rational(get('Exif.Photo.ExposureTime'))) 231 self.shutter_entry.set_text(str(get('Exif.Photo.ExposureTime')))
232 self.aperture_entry.set_text(to_fstop(from_rational(get('Exif.Photo.FNumber')))) 232 self.aperture_entry.set_text(to_fstop(str(get('Exif.Photo.FNumber'))))
233 self.lens_entry.set_text(from_rational(get('Exif.Photo.FocalLength'))) 233 self.lens_entry.set_text(str(get('Exif.Photo.FocalLength')))
234 234
235 self.description_entry.set_text(get('Exif.Image.ImageDescription')) 235 self.description_entry.set_text(get('Exif.Image.ImageDescription'))
236 extras, comments = decode_comments(get('Exif.Photo.UserComment')) 236 extras, comments = decode_comments(get('Exif.Photo.UserComment'))
@@ -284,13 +284,13 @@ class ExiFilm(object):
284 extras[FRONT_MOVEMENTS] = self.front_movements 284 extras[FRONT_MOVEMENTS] = self.front_movements
285 if self.rear_movements: 285 if self.rear_movements:
286 extras[REAR_MOVEMENTS] = self.rear_movements 286 extras[REAR_MOVEMENTS] = self.rear_movements
287 287
288 bounds = self.comments_buffer.get_bounds() 288 bounds = self.comments_buffer.get_bounds()
289 v = self.comments_buffer.get_text(bounds[0], bounds[1]) 289 v = self.comments_buffer.get_text(bounds[0], bounds[1])
290 if v or extras: 290 if v or extras:
291 self.image['Exif.Photo.UserComment'] = encode_comments(extras, v) 291 self.image['Exif.Photo.UserComment'] = encode_comments(extras, v)
292 292
293 self.image.writeMetadata() 293 self.image.write()
294 294
295 def window_closed(self, widget, data=None): 295 def window_closed(self, widget, data=None):
296 if self.image: 296 if self.image:
@@ -326,7 +326,7 @@ class ExiFilm(object):
326 self.front_button.set_label(self.front_movements) 326 self.front_button.set_label(self.front_movements)
327 else: 327 else:
328 self.front_button.set_label('None') 328 self.front_button.set_label('None')
329 329
330 def rear_clicked(self, widget, data=None): 330 def rear_clicked(self, widget, data=None):
331 moves = self.rear_movements.split('/') 331 moves = self.rear_movements.split('/')
332 moves = self.get_movements(moves) 332 moves = self.get_movements(moves)
@@ -354,7 +354,7 @@ class ExiFilm(object):
354 tree_store.append(None, (m,)) 354 tree_store.append(None, (m,))
355 if m in orig_movements: 355 if m in orig_movements:
356 tree_view.get_selection().select_path((i,)) 356 tree_view.get_selection().select_path((i,))
357 357
358 r = dialog.run() 358 r = dialog.run()
359 if r: 359 if r:
360 store, rows = tree_view.get_selection().get_selected_rows() 360 store, rows = tree_view.get_selection().get_selected_rows()
diff --git a/printrecord.py b/printrecord.py
index 65dc48a..f4ada9c 100644
--- a/printrecord.py
+++ b/printrecord.py
@@ -28,23 +28,23 @@ import lfrecord
28class MyImage(object): 28class MyImage(object):
29 def __init__(self, fn): 29 def __init__(self, fn):
30 if fn: 30 if fn:
31 image = pyexiv2.Image(fn) 31 image = pyexiv2.ImageMetadata(fn)
32 image.readMetadata() 32 image.read()
33 keys = image.exifKeys() 33 keys = image.exif_keys
34 self.image = image 34 self.image = image
35 else: 35 else:
36 keys = [] 36 keys = []
37 37
38 def get(key, default=''): 38 def get(key, default=''):
39 if key in keys: 39 if key in keys:
40 return image[key] 40 return image[key].value
41 return default 41 return default
42 42
43 self.date = get('Exif.Photo.DateTimeOriginal', '') 43 self.date = get('Exif.Photo.DateTimeOriginal', '')
44 44
45 self.shutter=from_rational(get('Exif.Photo.ExposureTime')) 45 self.shutter=str(get('Exif.Photo.ExposureTime'))
46 self.aperture=to_fstop(from_rational(get('Exif.Photo.FNumber'))) 46 self.aperture=to_fstop(str(get('Exif.Photo.FNumber')))
47 self.lens=from_rational(get('Exif.Photo.FocalLength')) 47 self.lens=str(get('Exif.Photo.FocalLength'))
48 48
49 self.description=get('Exif.Image.ImageDescription') 49 self.description=get('Exif.Image.ImageDescription')
50 extras, comments = decode_comments(get('Exif.Photo.UserComment')) 50 extras, comments = decode_comments(get('Exif.Photo.UserComment'))