Hi,
How to extract size and width of list of Images. Please help
Hi,
How to extract size and width of list of Images. Please help
If they are a list of images on a web site, after getting a selector for the image you can use the Get Attribute activity for “height” and “width”.
If they are images on the computer that method doesn’t seem to work, but you could pull up the properties of each image and scrape the Details tab to get the image size.
If you can’t find these, try “outerhtml” or “innerhtml” attribute.
Another way you can try is, if you have each Image as an element and if they are visible on screen:
element.Screenshot.Height.ToString
element.Screenshot.Width.ToString
If Desktop,
System.Drawing.Image.FromFile("path").Height.ToString
System.Drawing.Image.FromFile("path").Width.ToString
Use the UIExplorer on it first then click Property Explorer on the left. That will show you what attributes are available for that image.
Do you have innerhtml attribute at all? Not 100% sure, but since the image is responsive you may not get the height attribute as it can vary with screen size.
For the sake of it, try find element activity on image and you could do this if Image is clearly visible on screen.
element.Screenshot.Height.ToString
element.Screenshot.Width.ToString
Hi ,
How to and where to use this “element.Screenshot.Height.ToString”. Can you pls provide us an example.
Use it in write line to check the result.
3)write line height and width as shown above.
Thanks,
Vinay
Hi,
Its giving me the height of Screenshot. Is there any other way to capture exact size and width. I’ve multiple images in a page.
URL looks from a dell website, share the URL someone might be able to help.
Hi @vvaidya,
When I tried in Get attribute in Open browser activity unable to get height and width, but when use Get attribute directly im getting properties like height and width.
Hello, I used the method:
System.Drawing.Image.FromFile("path").Height.ToString
System.Drawing.Image.FromFile("path").Width.ToString
…to get the image properties and it works nicely.
However for further manipulations I would need to know how to close the processes used by system.drawing.image. Because after this step the images “are in use by another program”.
Running a separate uipath project “releases” the files, but is pretty inconvenient.
Update:
Might be common knowledge to most who know vb well but to release the images can use
imgVar.Dispose()