def get_exif_field_from_image(image, exif_field): """ Gets the exif field from an image """ exif_values = exif.getexif(image) k = list(exif_values.keys()) if exif_field in exif_values: return exif_values[exif_field]
def iminfo(f): try: info = cleanup_exif_tags(exif.getexif(f)) except exif.ExifException: info = {} if not "DateTime" in info: info["DateTime"] = file_time_creation(f) return info
def iminfo(f): try: info = cleanup_exif_tags(exif.getexif(f)) except Exception: info = {} if not "DateTime" in info: info["DateTime"] = file_time_creation(f) return info
def iminfo(f): try: info = cleanup_exif_tags(exif.getexif(f)) except exif.ExifException: info = {} if "DateTimeOriginal" in info: info["DateTime"] = info["DateTimeOriginal"] if "DateTime" not in info: info["DateTime"] = file_time_creation(f) return info
def dump_exif(f): print("File", f, ":") try: info = exif.getexif(f) except exif.ExifException as e: print(" Error:", e) else: for k, v in sorted(info.items()): print(" ", k, ":", user_repr(v)) print(" file creation time:", file_time_creation(f))
def dump_exif(f): print("File", f, ":") try: info = exif.getexif(f) except exif.ExifException as e: print(" Error:", e) else: for k in sorted([k for k in info if isinstance(k, str)]) + sorted([k for k in info if not isinstance(k, str)]): print(" ", k, ":", user_repr(info[k])) print(" file creation time:", file_time_creation(f))
def dump_exif(f): print("File", f, ":") try: info = exif.getexif(f) except exif.ExifException as e: print(" Error:", e) else: for k in sorted([k for k in info if isinstance(k, str)]) + sorted( [k for k in info if not isinstance(k, str)]): print(" ", k, ":", user_repr(info[k])) print(" file creation time:", file_time_creation(f))
def readPNG(filename, isMask=False, args=None): import itertools try: return ImageWrapper(_openCV2(filename), filename=filename) except Exception as ex: exifdata = exif.getexif(filename) if 'Bit Depth' in exifdata and exifdata['Bit Depth'] == '16': with open(filename, 'rb') as f: pngdata = png.Reader(file=f).asDirect() image_2d = np.vstack(itertools.imap(np.uint16, pngdata[2])) shape = image_2d.shape[1] / pngdata[0] if shape > 1: image_3d = np.reshape(image_2d, (pngdata[1], pngdata[0], image_2d.shape[1] / pngdata[0])) return ImageWrapper(image_3d, to_mask=isMask,filename=filename) else: return ImageWrapper(image_2d,filename=filename) else: raise ex
def get_exif(self): if self.filename is not None: return exif.getexif(self.filename) return None
def dump_exif(f): print "File", f, ":" try: info = exif.getexif(f) except exif.ExifException, e: print " Error:", e