def get_image_format(filename):
  """Returns image format from filename."""
  filename = filename.lower()
  if filename.endswith('jpeg') or filename.endswith('jpg'):
    return 'jpeg'
  elif filename.endswith('png'):
    return 'png'
  else:
    raise ValueError('Unrecognized file format: %s' % filename)