Skip to main content

Crop a region from an image to create a new image (:crop)

Declaration

cropped = img:crop([left, top, right, bottom])

Parameters

  • left, top, right, bottom
    Integer, optional. Region coordinates in the original image. Default 0, 0, img_width-1, img_height-1

Returns

  • cropped
    Image object. The cropped image

Description

Create a cropped copy from an existing image object
This call creates a new image object. For efficient frequent usage, please pair with image:destroy

Example

scrn = screen.image()
img2 = scrn:crop(100, 100, 200, 200)

Note: This example uses a function outside this chapter screen.image