import io


def pil_img_to_img_bin(pil_img):
  """Convert pil image to binary string.
  """
  output = io.BytesIO()
  pil_img.save(output, format="JPEG")
  img_bin = output.getvalue()
  return img_bin
  # img_bin = pil_img.tobytes()
  # return img_bin