Python Script - export images in table

Hi there,

I have a python script where some plots are created, which I need to pass to Knime. As I do not know in advance how many plots are created, I would like to store them in a table instead of using a static image port.

For testing purposes I tried to copy one image to the output dataframe / table:

output_image_1 = buffer.getvalue()
output_table_1 = pd.DataFrame(data={"ImageCol": output_image_1}, index=[0]).reset_index(drop=True)

It works, but then I get a column with a datatype of “Byte Vector”. How can I convert this column back into an image?

Hi @ActionAndi!

What you see is unfortunately expected, the Python script nodes do not support storing images in table cells. This is a feature request that’s quite high on our priority list, but we didn’t get to work on it yet.

For the time being, you could write PNGs to a temporary folder, store the file names in a column in the output table of your Python script and then use the “Read Images” node to read the images and continue with those as a workaround.

Does that help?


That’s a great idea!
The Python Code is part of a component which is shared to various colleagues. So it would be good to store the data in the local workflow folder/path.

But how do I get the absolute path from the current workflow?

@ActionAndi what you can do is store the PNG file in a SQLite database and then read it back into KNIME.

Just make sure that you have an actual PNG file (binary) and store it as a BLOB data type in SQLite. If you read it back to KNIME make sure the column “data” with the image is defined as a PNG file:

You might be able to combine these approaches:

You can extract the current surroundings from a node. I have also created a component for that:


Very good question, we’ll make paths to the workflow data area, KNIME’s temp folder etc available to Python scripts and nodes soon, but for now you could also use the “Extract Context Properties” node to access the path like I did in this example workflow include_python_library_in_workflow – KNIME Community Hub

Or use @mlauber71’s suggestions :slight_smile:


Thanks a lot!
I will save the images in the knime-temporary folder

1 Like

Thank you guys. Everything works fine now. The Speed-Up is massive!


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.