From fc0b6d7e73f09538b0b0bb0e98d8ddc451c24e24 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Wed, 19 Jun 2019 05:12:18 +0200 Subject: [PATCH] switch for base64 implementation --- clickslide.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/clickslide.sh b/clickslide.sh index e78f1c7..291130a 100755 --- a/clickslide.sh +++ b/clickslide.sh @@ -3,9 +3,13 @@ prev='' next='' idoff=0 depth=0 ucdepth=-1 -base64() { - uuencode -m - <"$1" \ - | sed '1d; :X;$!{N;bX;}; s;\n;;g; s;=\+;;g;' +_base64() { + { uuencode -m - <"$1" \ + | sed '1d; :X;$!{N;bX;}; s;\n;;g; s;=\+;;g;' + } || { + base64 <"$1" \ + | sed ':X;$!{N;bX;}; s;\n;;g; s;=\+;;g;' + } } { "${0%/*}"/cgilite/html-sh.sed || cat; } \ @@ -36,7 +40,7 @@ base64() { file="${file#\"}" file="${file%\"}" echo Inlining Background Image "$file" >&2 if [ -r "$file" ]; then - tag="${pre}url('data:image/${file##*.};base64,$(base64 "$file")')${post}" + tag="${pre}url('data:image/${file##*.};base64,$(_base64 "$file")')${post}" fi done >/dev/null @@ -47,7 +51,7 @@ base64() { file="${tag#${pre}src=\"}" file="${file%\"$post}" echo Inlining Image "$file" >&2 if [ -r "$file" ]; then - tag="${pre}src=\"data:image/${file##*.};base64,$(base64 "${file}")\"${post}" + tag="${pre}src=\"data:image/${file##*.};base64,$(_base64 "${file}")\"${post}" fi done >/dev/null -- 2.39.2