Hello @StarCrunch,
I am trying to use the impack plugin
-
“resize_rgb” and “resize_rgba”, to resize input image file into a thumbnail size data, and
-
“write.jpg” and “write.png”, to output the thumbnail data into a thumbnail image file.
However, it closes abruptly with this message on the simulator (on Windows) console,
The stdin connection has closed.
At the same time, a file appears in system.DocumentsDirectory with 0 size.
Below is the code I used for testing “jpg” images,
local function create_thumbnail( filename )
local data, w, h, comp = impack.image.load( filename ) -- jpeg image in system.ResourceDirectory
local scale = 0.15 -- scale for thumbnail
local newW = scale * w
local newH = scale * h
local resized = impack.ops.resize_rgb( data, w, h, newW, newH, comp )
print( filename, type( data ), string.len( data ), w, h, comp, newW, newH, type( resized ), string.len( resized ) )
-- output thumbnail image with filename in system.DocumentsDirectory
local okay, errMsg = impack.write.jpg( filename, newW, newH, comp, resized, { quality = 40 } )
print( okay, errMsg ) -- 2nd print statement
return okay, errMsg
end
The first print statement works. But it fails before the second print statement.
Please help to advise if there is anything I have missed out. Thank you.
PS> I am not able to test this on an Android device, as it crashes the simulator (on Windows). Also, I tried using different images to no avail.