code: def _get_asset(file_path):
      
      record = model.Image.get(file_path=file_path)
      fingerprint = ','.join((utils.file_fingerprint(file_path),
                              str(RENDITION_VERSION)))
      if not record or record.fingerprint != fingerprint:
          # Reindex the file
          logger.info("Updating image %s -> %s", file_path, fingerprint)
  
          # compute the md5sum; from https://stackoverflow.com/a/3431838/318857
          md5 = hashlib.md5()
          md5.update(bytes(RENDITION_VERSION))
          with open(file_path, 'rb') as file:
              for chunk in iter(lambda: file.read(16384), b""):
                  md5.update(chunk)
  
          values = {
              'file_path': file_path,
              'checksum': md5.hexdigest(),
              'fingerprint': fingerprint,
          }
  
          try:
              image = PIL.Image.open(file_path)
              image = fix_orientation(image)
          except IOError:
              image = None
  
          if image:
              values['width'] = image.width
              values['height'] = image.height
              values['transparent'] = image.mode in ('RGBA', 'P')
              values['is_asset'] = False
          else:
              # PIL could not figure out what file type this is, so treat it as
              # an asset
              values['is_asset'] = True
              values['asset_name'] = os.path.join(values['checksum'][:5],
                                                  os.path.basename(file_path))
          record = model.Image.get(file_path=file_path)
          if record:
              record.set(**values)
          else:
              record = model.Image(**values)
          orm.commit()
  
      return record
docs: Get the database record for an asset file