code: def check_structure(filepath):
      
      #http://stackoverflow.com/questions/1401527/how-do-i-programmatically-check-whether-an-image-png-jpeg-or-gif-is-corrupted/1401565#1401565
      
      # Check structure only for images (not supported for other types currently)
      if filepath.lower().endswith(tuple(img_filter)):
          try:
              #try:
              im = PIL.Image.open(filepath)
              #except IOError: # File format not supported by PIL, we skip the check_structure - ARG this is also raised if a supported image file is corrupted...
                  #print("File: %s: DETECTNOPE" % filepath)
                  #return None
              im.verify()
          # If an error occurred, the structure is corrupted
          except Exception as e:
              return str(e)
          # Else no exception, there's no corruption
          return False
      # Else the format does not currently support structure checking, we just return None to signal we didin't check
      else:
          return None
docs: Returns False if the file is okay, None if file format is unsupported by PIL/PILLOW, or returns an error string if the file is corrupt.