There is a new KNIME forum. You can still browse and read content from our old forum but if you want to create new posts or join ongoing discussions, please visit our new KNIME forum: https://forum.knime.com

How can get the size of an image as a variable?

Member for

3 years 6 months M42

The title says it: I want to know how large my image is, because I want to calculate things later on based on those measurements. How can I get the width and height of the image into a flow variable?

Comments
Thu, 01/25/2018 - 08:26

Member for

8 years 4 months

christian.dietz

Hi M42,

you can use the image properties -> collection splitter -> row to variable.

Does that work?

Best,

Christian

Fri, 01/26/2018 - 09:43

Member for

3 years 6 months

M42

Not quite. The Information is just output as a long string like

Image[name=myimage.png;source=;dimensions=2453,3462,3 (X,Y,Channel);min=38,20,0;pixel type=UnsignedByteType)]

Now, I could use some string manipulation to get the dimensions I guess, but isn't there a more elegant way?

If not, how would I do the string manipulation here?

Fri, 01/26/2018 - 12:45

Member for

6 years 6 months

gab1one

Hi M42,

take a look at the attached example workflow that demonstrates Christian's answer.

best,

Gabriel

Files