This commit is contained in:
2025-12-21 10:38:00 -06:00
parent 8941908553
commit ea3499db51
2 changed files with 48 additions and 19 deletions

View File

@@ -24,7 +24,7 @@ if (args.length < 2) {
log.console("Example: cell run convert.ce lenna.png lenna.qoi")
log.console("Decode: png, jpg, bmp, tga, gif, psd, qoi, ase/aseprite")
log.console("Encode: png, jpg, bmp, tga, qoi")
$_.stop()
$stop()
}
var input_file = args[0]
@@ -77,14 +77,14 @@ log.console("Loading input image: " + input_file)
var input_blob = io.slurp(input_file)
if (!input_blob) {
log.console("Error: Could not load input file: " + input_file)
$_.stop()
$stop()
}
var input_ext = ext_lower(input_file)
var decoded = decode_image(input_blob, input_ext)
if (!decoded) {
log.console("Error: Failed to decode image: " + input_file)
$_.stop()
$stop()
}
log.console("Image loaded: " + text(decoded.width) + "x" + text(decoded.height) + " pixels")
@@ -92,7 +92,7 @@ log.console("Image loaded: " + text(decoded.width) + "x" + text(decoded.height)
var output_ext = ext_lower(output_file)
if (!output_ext) {
log.console("Error: Could not determine output format from: " + output_file)
$_.stop()
$stop()
}
log.console("Converting to format: " + output_ext)
@@ -100,13 +100,13 @@ log.console("Converting to format: " + output_ext)
var encoded = encode_image(decoded, output_ext)
if (!encoded) {
log.console("Error: Failed to encode image to format: " + output_ext)
$_.stop()
$stop()
}
var success = io.slurpwrite(output_file, encoded.pixels)
if (!success) {
log.console("Error: Could not save output file: " + output_file)
$_.stop()
$stop()
}
log.console("Successfully converted " + input_file + " to " + output_file)