-- requirements:
-- + parent script "BASE64"
-- http://valentin.dasdeck.com/lingo/binary_file_encoding/base64/d10/BASE64.LS
-- + movie script "FILE_FILEIO" (D10- version):
-- http://valentin.dasdeck.com/lingo/binary_file_interface/d10/FILE_FILEIO.LS
on test_encode
ms = the milliseconds
b64 = script("base64_class").new()
binStr = file_get_bytes(_movie.path & "test.jpg")
--b64.setMimeHeader("test.jpg") -- save original filename in header (optional)
--b64.setMimeHeader("test.jpg", "image/jpeg") -- or save both original filename and mimetype (optional)
str = b64.base64Encode(binStr) -- optional: pass TRUE as 2. arg to slit in lines
ok = file_put_string(_movie.path & "test.jpg.b64", str)
put (the milliseconds-ms) && "ms"
end
on test_decode
ms = the milliseconds
b64 = script("base64_class").new()
str = file_get_string(_movie.path & "test.jpg.b64")
binStr = b64.base64Decode(str)
ok = file_put_bytes(_movie.path & "new.jpg", binStr)
put (the milliseconds-ms) && "ms"
end