code: def check_image_format(fformat):
      
      cases = {"jpg": "jpeg",
               "jpeg": "jpeg",
               "tif": "tiff",
               "tiff": "tif",
               "pgm": "ppm",
               "pbm": "ppm",
               "ppm": "ppm",
               "bmp": "bmp",
               "dib": "bmp",
               "gif": "gif",
               "im": "im",
               "pcx": "pcx",
               "png": "png",
               "xbm": "xbm",
               "xpm": "xpm",
               'jp2': 'jp2',
               }
      fformat = fformat.lower()
      try:
          fformat = cases[fformat]
      except KeyError:
          raise UnknownImageFormat("Unknown image format '%s'." % fformat)
      return fformat
docs: Check that *fformat* is valid