dymokomi/luce-develop
Source of release 0.1.0
0.1.0 / tests / develop_check.lucb
## Develop each file on the command line on the CPU, at 1024 px, with the
## settings given first ("" for the defaults), into OUTPUT_DIR/<name>.jpg.
import time
from luce_std import paths
import strings
from luce_develop import scene
from luce_develop import process
from luce_develop import settings
from luce_develop import geometry
pub func main(arguments: str[]) -> i32!:
if arguments.length < 4:
print("usage: develop_check OUTPUT_DIR SETTINGS FILE...")
return 2
let wanted = settings.parse(arguments[2])
for path in arguments[3..]:
let started = time.now()
var opened = try scene.open(path, 1024)
defer opened.close()
let loaded = (time.now() - started) // 1000000
# Guides decide the perspective, as an editor solves them.
var solved = wanted
geometry.solve(&solved, (f64)opened.width(), (f64)opened.height())
if solved.guides().length > 0:
print(f" solved: rotate {solved.get(.geometry_rotate)} vertical {solved.get(.geometry_vertical)} horizontal {solved.get(.geometry_horizontal)}")
var picture = try process.render(&opened, solved)
defer picture.close()
let spent = (time.now() - started) // 1000000
var buffer: u8[1024]
let target = try strings.format(buffer, f"{arguments[1]}/{paths.base(path)}.jpg")
try picture.save_jpeg(target, 90)
print(f"ok {paths.base(path)} {picture.width()}x{picture.height()} as shot {(i64)opened.shot_temperature} K load {loaded} ms total {spent} ms")
return 0