-
Notifications
You must be signed in to change notification settings - Fork 0
/
lua-braille.lua
31 lines (25 loc) · 1005 Bytes
/
lua-braille.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
local pngLua_folder = "pngLua/"
package.path = pngLua_folder .. "?.lua;" .. package.path
require 'lib.braille'
require 'lib.params'
function outputBraille(lines)
for key, line in pairs(lines) do
print(line)
end
end
if arg[1] == '?' or arg[1] == '-h' or arg[1] == '--help' then
print(arg[0])
print("script help to convert *.png image into braille unicode table")
print("usage:")
print(" lua lua-braile.lua <img_path> <grayscale_mode_index> <compression>")
print(" <img_path> - path to image in .png format")
print(" <compression> - parameter from 0.0 to 0.99 of image size compression")
print(" <grayscale_mode_index> {'luminance', 'lightness', 'average', 'value'}")
else
local img_path, grayscale_mode, compression_val = arg[1], arg[2], arg[3]
local img = pngImage(img_path)
local pr = Params:init()
pr:set_compression(compression_val and tonumber(compression_val) or 0.0)
pr:set_grayscale(grayscale_mode and tonumber(grayscale_mode) or 3)
outputBraille(canvasToTable(img, pr))
end