52
51
def is_readable_format(format):
53
52
"""Returns True if pyexiv2 can read Exif or Iptc metadata from
54
53
the image file ``format``."""
55
return not format or format in READ_EXIF+READ_IPTC+READ_COMMENT
54
return not format or format in READ_EXIF + READ_IPTC + READ_COMMENT
58
57
def is_writable_format(format):
59
58
"""Returns True if pyexiv2 can write Exif or Iptc metadata to
60
59
the image file ``format``."""
61
return not format or format in WRITE_EXIF+WRITE_IPTC+WRITE_COMMENT
60
return not format or format in WRITE_EXIF + WRITE_IPTC + WRITE_COMMENT
64
63
def is_writable_format_exif(format):
99
98
#2. exclude tags which (might) break exiv2 (eg Canon tuples)
100
# This will probably be obsolete for python-pyexiv2 0.2
101
# -> If that is True add a version check
101
103
#verify if there are tags which might break exiv2
103
for tag in list(source_pyexiv2_image.exifKeys())+\
106
for tag in list(source_pyexiv2_image.exifKeys()) + \
104
107
list(source_pyexiv2_image.iptcKeys()):
105
108
if RE_BROKEN.match(tag):
106
broken_tags.append(RE_BROKEN)
109
broken_tag = RE_BROKEN
111
for broken_tag in broken_tags:
112
#attempt to copy metadata
114
warnings = _copy_metadata(source_pyexiv2_image, target,
115
source_format, target_format, broken_tag, thumbdata)
117
except Exception, message:
120
#if metadata copied succesfully, check for warnings
123
log += ISSUES%target+warnings
125
log = FAILED%(target, message, BROKEN)
115
#attempt to copy metadata
117
warnings = _copy_metadata(source_pyexiv2_image, target,
118
source_format, target_format, broken_tag, thumbdata)
120
except Exception, message:
123
#if metadata copied succesfully, check for warnings
126
log += ISSUES % target + warnings
128
log = FAILED % (target, message, BROKEN)
160
164
source_pyexiv2_image._Image__getExifTag(tag)[1])
162
166
except Exception, message:
163
message = '%s: %s'%(tag, message)
167
message = '%s: %s' % (tag, message)
164
168
warnings.append(message)
165
169
#copy iptc metadata
166
170
if (not source_format or source_format in READ_IPTC) and \
170
174
target[tag] = source_pyexiv2_image[tag]
172
176
except Exception, message:
173
message = '%s: %s'%(tag, message)
177
message = '%s: %s' % (tag, message)
174
178
warnings.append(message)
176
180
if (not source_format or source_format in READ_COMMENT) and \