From a54d714192b1bc8befa2afbfee8ce28df1e88adc Mon Sep 17 00:00:00 2001 From: Morgan Williams <2504532+mrgnw@users.noreply.github.com> Date: Fri, 10 Apr 2026 13:00:50 +0200 Subject: [PATCH] jxl: auto-convert unsupported formats (HEIC, WEBP, etc.) via sips cjxl only accepts a limited set of input formats. For anything else (e.g. HEIC from iPhone), convert to PNG intermediary via sips first. Temp file is cleaned up via EXIT trap. Co-Authored-By: Claude Opus 4.6 (1M context) --- jxl | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/jxl b/jxl index 9d70b25..aef39cf 100755 --- a/jxl +++ b/jxl @@ -1,8 +1,23 @@ #!/bin/bash +SUPPORTED_RE='\.(jpe?g|png|apng|gif|exr|ppm|pnm|pfm|pam|pgx)$' + +convert_if_needed() { + local input="$1" + if echo "$input" | grep -iqE "$SUPPORTED_RE"; then + echo "$input" + return + fi + local tmp="${TMPDIR:-/tmp}/jxl-$$-$(basename "${input%.*}").png" + sips -s format png "$input" --out "$tmp" >/dev/null 2>&1 || { echo "Failed to convert $input" >&2; exit 1; } + echo "$tmp" +} + if [ $# -eq 1 ]; then - base="${1%.*}" - cjxl "$1" "${base}.jxl" + base="${1%.*}" + input="$(convert_if_needed "$1")" + [ "$input" != "$1" ] && trap 'rm -f "$input"' EXIT + cjxl "$input" "${base}.jxl" else - cjxl "$@" -fi \ No newline at end of file + cjxl "$@" +fi -- knotmirror 0.0.1