def getfiledate(filename): """ This takes a filename and tries to read the last modification date from exif or filesystem. """ try: filedate = ExifHandler.getfiledate(filename) except: try: filestat = os.stat(filename) filedate = datetime.datetime.fromtimestamp(filestat.st_mtime) logging.info("Can not read EXIF date, using file system date.") except: logging.error("Can not access file modification date for %s, skipping." % filename) return None return filedate
def display(self, imagename): """ Loads image from preview or file and converts it properly. """ if self._loadedimage != imagename: self._imagedata = ExifHandler.getthumbnail(imagename) if self._imagedata is not None: self._loadedimage = imagename try: imagewidth = (float)(self._imagedata.GetWidth()) imageheigth = (float)(self._imagedata.GetHeight()) panelwidth, panelheight = self.GetSizeTuple() scale = imagewidth/(float)(panelwidth) if (imageheigth/panelheight) > scale: scale = imageheigth/(float)(panelheight) self._drawdata = self._imagedata.Copy() self._drawdata.Rescale(imagewidth/scale, imageheigth/scale) self.Refresh(True) except: logging.error("Can not convert image, no preview.")