degal/image.py
changeset 111 ecceaf23c969
parent 91 17ae33501289
child 115 d5aa320697df
equal deleted inserted replaced
110:a5b30b423f79 111:ecceaf23c969
    72             Load and return the metadata for the image as a dictionary
    72             Load and return the metadata for the image as a dictionary
    73         """
    73         """
    74 
    74 
    75         # load stuff
    75         # load stuff
    76         stat = self.stat()
    76         stat = self.stat()
    77         exif = self.exif
       
    78 
    77 
    79         # XXX: avoid having to open the image?
    78         # XXX: avoid having to open the image?
    80         size = self.pil_image.size
    79         size = self.pil_image.size
    81         
    80         
    82         # build
    81         # build
    83         return dict({
    82         metadata = dict({
    84             "File name":        self.name,
    83             "File name":        self.name,
    85             "Resolution":       "%dx%d" % size,
    84             "Resolution":       "%dx%d" % size,
    86             "File size":        format.filesize(stat.st_size),
    85             "File size":        format.filesize(stat.st_size),
    87             "Last modified":    format.filetime(stat.st_mtime),
    86             "Last modified":    format.filetime(stat.st_mtime),
    88         }, **dict(
    87         })
    89             (name, exif[tag]) for tag, name in self.config.exif_tags if exif and tag in exif
    88         
    90         ))
    89         # optionally load Exif metadata
       
    90         if self.config.exif_enabled :
       
    91             exif = self.exif
       
    92 
       
    93             # Get the wanted tags
       
    94             metadata.update(dict(
       
    95                 (name, exif[tag]) for tag, name in self.config.exif_tags if exif and tag in exif
       
    96             ))
       
    97 
       
    98         return metadata
    91     
    99     
    92     def stale (self) :
   100     def stale (self) :
    93         """
   101         """
    94             Tests if this Image is stale, based on preview/thumb.
   102             Tests if this Image is stale, based on preview/thumb.
    95         """
   103         """