Has anyone tried storing images in PostgreSQL using KNIME? How was the workflow? Below is my current workflow, I have no idea what should I do now.
Well I think it depends on what you want to achieve.
What I think won’t work is storing a plain image as jpg or png.
You definitely can store a link (although by the looks of it that’s not what you seem to be after) or probably an image converted to binary format.
There’s PNG to binary node:
And for non png you could use ImgPlus to png
To then get int into the DB there’s an example from @takbb here:
In general I think you have to set the column in your DB to type binary in the insert node.
I totally agree with Martin. You have to convert the images into binary format before you can store them in a database.
But be sure if you have many of them it may bloat your DB.
May I know is there any way to convert binary object?
Check the link Martin provided
@Is_celine you can create an entry in a PostgeSQL database like this
CREATE TABLE images (
id NUMERIC(5),
image_binary BYTEA
);
And then upload a binary file. I adapted an example by @takbb .
Now i having an issues in converting binary format, there’s no data under the out_image_binary. I have formatting the image into PNG format then use PNG to Binary Objects node to convert it, but it couldn’t work.
I don’t have a computer with me right now as I’m traveling, but looking at the screenshot: are you sure images are of type png (from Knime data type perspective)?
Can you use imgPlus node I shared above to convert image column to png and then use that to turn into binary?
What’s the Java snippet doing?
Convert it to PNG format. If I did not use this code, the ImPlus node could not connect to PNG to binary object
Hi,
isn’t the “ImgPlus to PNG Images” node creating png format?
There’s a “PNG Image to ImgPlus” Node. If you place it behind the java node it should produce exactly the same data which enters the “ImgPlus to PNG Images”.
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.