Data Shapes resize inserted image

Hello all, i have been looking far and wide for a way to resize an imported image in a MULTIINPUTFORM from datashapes. No matter what size my image is, the node resizes it to the same size.

I have found this in the Python script in the Multiple inputform :

			elif j.__class__.__name__ == 'uiimage':
				pic = Image.FromFile(j.image)
				im = PictureBox()
				if j.showborder:
					im.BorderStyle = BorderStyle.Fixed3D
				else:
					im.BorderStyle = BorderStyle.None
				ratio = (pic.Height)/(pic.Width)
				h = float(pic.Height)
				w = float(pic.Width)
				ratio = h/w
				image_maxsize = formwidth - xlabel - rightmargin
				im.Size = Size(image_maxsize,image_maxsize*ratio)
				scaledimage = Bitmap(image_maxsize,image_maxsize*ratio)
				gr = Graphics.FromImage(scaledimage)
				gr.DrawImage(pic,0,0,image_maxsize,image_maxsize*ratio)
				im.Image = pic
				im.SizeMode = PictureBoxSizeMode.Zoom
				formbody.Controls.Add(im)
				im.Location = Point(25 * xRatio,y+25*yRatio)
				y = im.Bottom + 25 * yRatio

Can someone confirm that the only way for me to change how the node UI.Image Data resizes an image is by editing the code in the MultipleInputForm ?

As reference the nodes i am using:
Dynamo 2.0.3

image

To add an example, see the screenshot below.

I have inserted a red image with a total size of 1 pixel. This picture gets stretched to a size that is standard in the image box from data shapes.

Is there a way to remove this stretching from happening? I can understand a maximum width and height for an image but a default measurement for all sizes is giving me very unclear images

Yes, you are right. You have to edit, as you like.

Hi @MVE1112 @Deniz_Maral through data shapes image data input is not working for me. It is giving me an error like below,

can you please tell me how shall I proceed with ?

Got it @Deniz_Maral @MVE1112 I was feeding the file but I need to feed only the file path right(which is in string value.

Regards

1 Like