HOW TO RESIZE THE HEIGHT AND WIDTH OF THE IMAGE

I want to capture the screen of a website with the “Take Screenshoot” activity

The screenshot will be a “png” file and then I want the image to be immediately resized in width and height.

After that, it was saved to the image folder and given a file name according to the excel data that I had
image

I made a flow like this is it correct? but how to resize the height and width of the image?

hello @Kia1 ,

you can use HTML template to give size of your image
just we need to convert into ToBase64String.

"<img src=""data:image/jpg;base64,byte_stringVariable"""+"Width=""320"" height=""250"" " +"/>"

below screenshot is for your reference

lastly HTML_tag you can use in your templete.

i am attaching .xaml file for your reference

demo.xaml (8.0 KB)

Regards,
Dheerendra Vishwakarma

Is this implemented after or before the take screenshot activity?

@Kia1

what i have done is i have placed images in local folder and used html template to give size

image
I experienced an error in the byte_arr assignment section

We can do it by a flow like this:
grafik

here a formal specification on how the scaling / scalefactor is defined is recommended. But we can dynamic calculate it and also add to the implementation parts

what is the “myImage” variable for?

Activating the Take Screenshot Activity and Pressing F1 brings us to:

and we can check:
grafik

which is a variable of DataType:
grafik

We recommend to have an understanding on what is done. Instead of:

  • Taking Screenshot - writing file - reading file - scaling file - writing scaled file

we just do:

  • Taking Screenshot - scaling file - writing scaled file

image
Argument ‘Image’: BC30057: Too many arguments to ‘Public Overloads Function Scale(scaleFactor As Double) As Image’.

I experienced an error, the myImg variable was already of image type

then where do I give the image height and width values?

We recommend to check what is needed and expected within the functions

we mentioned but it was not answered
yourScaleFactor is of DataType double e.g. 0.75 = 75%, 0.45 …

As you gave too numbers, it was causing the factor.

So let us know in detail what is needed we can help on:

  • calculating the scalefactor (as mentioned and offered above)
  • checking for alternate scaling options

Kindly note: we recommend a proportional scaling. Does mean

  • do scale with the same factors on witdth and hight

The original image size is Width: 960px Height: 450px

I want to change it to Width : 429px , Height : 201px

429 / 960 = 0.446875
201/ 450 = 0.4466

So we dont have a proportional scaling, but close as
450 * 0.446875 = 201.09375

So we can calculate the scale factor by

@Kia1 ,
what you have put in byte_arr assign
can you show me? so that we can help you

@Kia1
we recommend to focus 1 approach - implement it to end / success
And THEN explore alternates
But do not work on multiple approaches in parallel

@Dheerendra_vishwakarma
we don’t see a need of:
grafik

An UiPath.Core.Image gives us already the Base64 String by
grafik

1 Like

@Kia1
yes as @ppr is saying right just go for one approach then find the alternative way.


I’ve fixed the robot running smoothly, but when I check the image size it doesn’t change

Should I change the part that I circled in yellow to my path name?

@Kia1
your image is in png format
try this if it work

"<img src=""data:image/png;base64,byte_stringVariable"""+"Width=""320"" height=""250"" " +"/>"

Regards

Sequence2.xaml (10.0 KB)
I have a UiPath flow like this, is it possible without using the “For each file in folder” activity? because I already have my own loop.

what variables can I write to “load image”?

We recommend scoping 1 Topic = 1 use case

The description from begin and the Flow from above are much different and we risk a ping-pong communication losing a straightforward progress to solution

we recommend not to ommit the loop over the files e.g. with black-boxing it with an invoke code.

However the part of:
grafik

can be condensed to
grafik

We do feel that the topic can be closed now: