Save image to Photos (:save_to_album)
Declaration
img:save_to_album()
Description
Export the image to the system Photos app
Example 1
-- Download a small image from the web and save it to Photos
local c, h, r = http.get("https://www.xxtouch.app/img/Logo.png", 10)
if (c == 200) then
local img = image.load_data(r)
img:save_to_album()
sys.alert("Image saved to Photos")
else
sys.alert("Download failed")
end
Note: This example uses functions outside this chapter sys.alert
, http.get
Example 2
-- Capture full screen and save to Photos
screen.image():save_to_album()
Note: This example uses a function outside this chapter screen.image
Example 3
-- Save a file to Photos (example only; add existence checks before saving)
image.load_file("/var/mobile/1.png"):save_to_album()
Example 4
-- Save a file to Photos with type checks
img = image.load_file("/var/mobile/1.png")
if image.is(img) then
img:save_to_album()
end