Skip to main content

Save image as a JPEG file (:save_to_jpeg_file)

Declaration

img:save_to_jpeg_file(path [, quality ])

Parameters

  • path
    String. Absolute path to save the JPEG file
  • quality
    Number, optional. Image quality, in range 0.0~1.0. Default 1.0

Description

Save the image object to a JPEG file. The file extension does not have to be .jpg

Example

-- Capture full screen and save to file
screen.image():save_to_jpeg_file("/var/mobile/1.jpg")
-- Save with lower quality (lossy compression)
screen.image():save_to_jpeg_file("/var/mobile/1.jpg", 0.4)

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