Skip to main content

Capture Screen Image (screen.image)

Declaration

img = screen.image([ left, top, right, bottom ])

Parameters

  • left, top, right, bottom
    Integer, optional. Image region. Default is full screen.

Returns

Description

Capture the image of the full screen or a region.
This method creates a new image object. For frequent usage, consider calling image:destroy to release memory in time: see image:destroy.

Example

-- Examples of screen.image
--
screen.image():save_to_album() -- Full-screen screenshot to album
--
screen.image():save_to_png_file("/var/mobile/1.png") -- Full-screen screenshot to file
--
screen.image(100, 100, 200, 200):save_to_album() -- Capture region and save to album
--
pasteboard.write(screen.image(100, 100, 200, 200):png_data(), "public.png")
-- Write captured region into pasteboard as PNG

Note: Uses :save_to_album:save_to_png_file:png_datapasteboard.write