def get_image_media_type(img_ext):
    """Return media type for image based on extension.
  """
    if '.' in img_ext:
        img_ext = img_ext.split('.')[-1]
    img_ext = img_ext.lower()
    assert img_ext in ['bmp', 'tiff', 'tif', 'png', 'jpg', 'jpeg'
        ], 'image format must be one of png, jpg, jpeg, tif, tiff, bmp.'
    if img_ext in ['jpg', 'jpeg']:
        return 'image/jpeg'
    if img_ext == 'png':
        return 'image/png'
    if img_ext in ['bmp']:
        return 'image/bmp'
    if img_ext in ['tif', 'tiff']:
        return 'image/tiff'
