]> Frank Brehm's Git Trees - my-stuff/python.git/commitdiff
Added set-jpeg-comment.sh
authorFrank Brehm <frank.brehm@profitbricks.com>
Mon, 28 Sep 2015 09:45:34 +0000 (11:45 +0200)
committerFrank Brehm <frank.brehm@profitbricks.com>
Mon, 28 Sep 2015 09:45:34 +0000 (11:45 +0200)
set-jpeg-comment.sh [new file with mode: 0755]

diff --git a/set-jpeg-comment.sh b/set-jpeg-comment.sh
new file mode 100755 (executable)
index 0000000..074bc68
--- /dev/null
@@ -0,0 +1,43 @@
+#!/bin/bash
+
+
+set -e
+set -u
+
+
+usage() {
+    cat <<EOF
+Usage: ${0} <IMAGE_FILE> [COMMENT]
+
+EOF
+}
+
+if [[ "$#" -lt 1 ]] ; then
+    echo -e "No image file given.\n" >&2
+    usage >&2
+    exit 1
+fi
+
+IMAGE_FILE="${1}"
+shift
+
+if type -t rdjpgcom >/dev/null ; then
+    :
+else
+    cat >&2 <<-EOF
+       Executable rdjpgcom  not found.
+
+       Please install package libjpeg-progs (Debian/Ubuntu) or media-libs/libjpeg-turbo (Gentoo).
+
+       EOF
+    exit 5
+fi
+
+if [[ ! -f "${IMAGE_FILE}" ]] ; then
+    echo -e "File '${IMAGE_FILE}' not found.\n" >&2
+    usage >&2
+    exit 1
+fi
+
+
+# vim: et ts=4 softtabstop