Image Cropping


#1

How to crop an image in UIPath?Is there any activity for Image Cropping in Ui Path?


#2

Can you provide some information regarding your scenario where you want to crop the image? @Teja1

Thanks,
Sreekanth.k


#3

Hi @Teja1,
@sreekanth,

There is no activity related to cropping image activity in uipath.

You can create custom activity to resize your image using below code.

Regards,
Arivu


#4

Use Graphics.DrawImage Method (Image, RectangleF, RectangleF, GraphicsUnit) method.

Dim fileName = "C:\file.jpg"
Dim CropRect As New Rectangle(100, 0, 100, 100)
Dim OriginalImage = Image.FromFile(fileName)
Dim CropImage = New Bitmap(CropRect.Width, CropRect.Height)
Using grp = Graphics.FromImage(CropImage)
    grp.DrawImage(OriginalImage, New Rectangle(0, 0, CropRect.Width, CropRect.Height), CropRect, GraphicsUnit.Pixel)
    OriginalImage.Dispose()
    CropImage.Save(fileName)
End Using

#5

Try this code using Invoke activity

Regards,
Arivu