A bug in UiPath.Core.Image -> CropImage

The Image’s CropImage function has following parameters: elementRegion, nodeClippingRegion, expand.

When trying to crop an image there’s a problem when using expand value False. For some reason the image isn’t cropped by the elementRegion or nodeClippingRegion values as it should. You can verify this bug by trying to crop bigger image (bigger than: width: 600px, height: 318px).

With expand value True, it crops the image correctly, but it automatically adds more content outside the elementRegion parameters region, which is not helpful in my case.

Br. Ville

OK … it’s not really a bug … it’s just really badly documented.
there is an argument in CropImage that you MUST set to FALSE or you get a ridiculous border … have absolutely no idea why this has been created like this !!!

I’m going to tell you how to do it because I don’t want you to have go through the ball-ache that I have just gone through !!!

you need two Assign activities
First. use a Load Image activity to Load your image into an image variable
Second. create a rectangle object
Third. crop the image using the rectangle object

  1. looks like this
    ASSIGN ACTIVITY
    on the left put : regionCropping (or whatever you want to call it) but this has to be of the type UiPath.Core.Region
    on the right put : New uipath.core.Region(New Rectangle(233,680,178,37))

  2. looks like this
    ASSIGN ACTIVITY
    on the left put : imgCropped (or whatever you want to call it) but it has to be of the type UiPath.Core.Image
    on the right put : imgTest01.CropImage(regionCropping , , False,)
    you have to have False in there or your image will come with a ridiculous border !?!

Hope that helps … I don’t want anyone to have to go through the days of frustration that I have had … absolutely no documentation about this function … hope this makes amends !
And here’s the file … hope you find it useful.
CropImages02.xaml (6.5 KB)

1 Like

Hi, this post has been here over 3 years now and the original issue was solved by going through entirely different route (can’t remember exactly how it went anymore).

Even still, your solution is great way to solve the issue :slight_smile:.
Hopefully anyone else struggling with this, finds this post as it clearly solves the issue perfectly.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.