bluedxca93
Newcomer
- Joined
- Mar 13, 2021
- Messages
- 2
- Reaction score
- 0
Am thinking of a script to autocrop small pngs using lua 5.1 and imlib2 on ubuntu.
while doing this i did get the idea of writing the following code:
What i want there is that temp_top is a variable in lua and that it only is defined for the biggest temp_top possible inside that for loop and exported to a variable called top_margin that i can use later.
inside scripts,zip i did the following hackish workaround:
lua script.lua > offset-analyz; cat offset-analyz | sort -r | grep -m 1 top;.
This does export top_margin in a way i can use it in bash. That works but there schould be a way to do it entirely in lua.
while doing this i did get the idea of writing the following code:
Code:
for y=0, xhalf do
c1 = im:get_pixel(xmid, y)
c1a = (c1.alpha)
if c1a < 20 then temp_top=y io.stdout:write( "top_margin=",y+1, "\n") end
end
inside scripts,zip i did the following hackish workaround:
lua script.lua > offset-analyz; cat offset-analyz | sort -r | grep -m 1 top;.
This does export top_margin in a way i can use it in bash. That works but there schould be a way to do it entirely in lua.