How to add new image to existing dataset?

Let’s say you have a dataset on the hub, containing some images:

from datasets import load_dataset

dataset = load_dataset("hf-internal-testing/example-documents")

How can I add a new image to it?

I tried:

from PIL import Image

image ="/content/cord_example.png").convert("RGB")

new_image = {'image': image}
dataset['test'] = dataset['test'].add_item(new_image)

but this fails with:

ArrowInvalid: Could not convert <PIL.Image.Image image mode=RGB size=576x864 at 0x7F7CCC4589D0> with type Image: did not recognize Python value type when inferring an Arrow data type

Update: seems like I figured it out. Solution:

import datasets

feature = datasets.Image(decode=False)
new_image = {'image': feature.encode_example(image)}
dataset['test'] = dataset['test'].add_item(new_image)

I think feature encoding should be done inside add_item, do you mind opening an issue on github ?