Official Content

The task of image manipulation is quite common in applications that handle images. Common actions include: resizing, scaling, rotating, cropping, flipping horizontally and vertically, etc.

To allow the performance of such actions on images, GeneXus has added certain functions to the Image data type.

Properties

ImageWidth: Numeric

Read-only property. Returns the image width in pixels.

&width = &image.ImageWidth

 

ImageHeight: Numeric

Read-only property. Returns the image height in pixels.

&height = &image.ImageHeight

 

FileSize: Numeric

Read-only property. Returns the image's file size in bytes.

&fileSize = &image.FileSize

Methods

The following methods do not modify the original image, they always return a new image with the modifications.

Resize

Returns a new image by resizing the original image.

Parameters:

  • Width: Numeric - width of the new image,
  • Height: Numeric - height of the new image,
  • KeepAspect: Boolean, when set to True, the image is resized using "fill keeping aspect". Otherwise, "fill" is used.
&resizedImage = &image.Resize(100, 100, true)

Scale

Returns a new image by scaling the original image to the specified percentage.

Parameters:

  • Percentage: Numeric.
&scaledImage = &image.Scale(80)

Rotate

Returns a new image by rotating the original image in the specified angle. Valid angles are 90, 180, and 270 degrees; other values are ignored.

Parameters:

  • Angle: Numeric.
&rotatedImage = &image.Rotate(90)

Crop

Returns a new image by cropping a portion of the original image. The dimensions of the new image are determined from the square indicated by the parameters.

Parameters:

  • Left: Numeric - left coordinate in pixels where the cropping begins.
  • Top: Numeric - top coordinate in pixels where the cropping begins.
  • Width: Numeric - width of the new image in pixels.
  • Height: Numeric - height of the new image in pixels.
&croppedImage = &image.Crop(0, 0, 50, 50)

FlipHorizontally

Returns a new image from the original image, rotated horizontally.

&hFlippedImage = &image.FlipHorizontally()

FlipVertically

Returns a new image from the original image rotated vertically.

&vFlippedImage = &image.FlipVertically()

RoundBorders

Returns a new image identical to the original, but with rounded edges.

Parameters:

  • topLeftRadius: Numeric - number of pixels defining the radius of curvature in the upper left corner.
  • topRightRadius: Numeric -  number of pixels defining the radius of curvature in the upper right corner.
  • bottomLeftRadius: Numeric - number of pixels defining the radius of curvature in the lower left corner. 
  • bottomRightRadius: Numeric - number of pixels defining the radius of curvature in the lower right corner.

For example, you can use RoundBorders to get a circular shaped image. To achieve this, you can take a square image (same width and length) and do the following: 

&radius=&image.ImageWidth/2 
&image.RoundBorder(&radius, &radius, &radius, &radius)

Availability 

RoundBorders Method is available for .NET, .NET Framework and Java since GeneXus 18 Upgrade 6

Scope

See also 

Image data type

Last update: February 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant