Resizes the canvas to the given dimensions.
This does not scale the image but simply changes the dimensions of the canvas on which the image is sitting.
Specifying a larger size will pad the image with a background color and specifying a smaller size will crop the image. This is the operation most people want when they think of crop.
We can specify a position which will be used to anchor the source image in the new canvas.
When resizing, we can specify a factor to multiply the current dimensions by, such as
or we can specify target sizes specifically, such as
image.resizeTo(400,300), or we can resize the width or
Using this image as our input:
// with added colour to show the padded canvas image.resizeTo(400, 400, Color.MAGENTA)
// anchoring the source to the bottom right corner image.resizeTo(400, 300, Position.BottomRight)
// resizing only one dimension image.resizeToWidth(400)