From 2b3f7985ffa092aed214765829362adb6affe364 Mon Sep 17 00:00:00 2001
From: Sergey Matveev <stargrave@stargrave.org>
Date: Thu, 26 Aug 2021 12:57:15 +0300
Subject: [PATCH] JPEG-XL transcoding scripts

---
 bin/bin/transcode-jp2.sh | 7 +++++++
 bin/bin/transcode-jpg.sh | 7 +++++++
 2 files changed, 14 insertions(+)
 create mode 100755 bin/bin/transcode-jp2.sh
 create mode 100755 bin/bin/transcode-jpg.sh

diff --git a/bin/bin/transcode-jp2.sh b/bin/bin/transcode-jp2.sh
new file mode 100755
index 0000000..97c1f45
--- /dev/null
+++ b/bin/bin/transcode-jp2.sh
@@ -0,0 +1,7 @@
+#!/bin/sh -e
+
+ppm=${1%.jp2}.ppm
+trap "rm -f $ppm" HUP PIPE INT QUIT TERM EXIT
+opj_decompress -i $1 -o $ppm
+cjxl $ppm ${1%.jp2}.jxl -q 100 -e 9 -p
+rm $1
diff --git a/bin/bin/transcode-jpg.sh b/bin/bin/transcode-jpg.sh
new file mode 100755
index 0000000..882cce1
--- /dev/null
+++ b/bin/bin/transcode-jpg.sh
@@ -0,0 +1,7 @@
+#!/bin/sh -e
+
+trap "rm -f \"$1\".jpegtran.jpg" HUP PIPE INT QUIT TERM EXIT
+jpegtran -optimize -progressive -perfect -copy all "$1" > "$1".jpegtran.jpg
+cjxl "$1".jpegtran.jpg "${1%.*}.jxl" -q 100 -e 9
+[ -s "${1%.*}.jxl" ]
+rm "$1"
-- 
2.51.0