summaryrefslogtreecommitdiff
path: root/jpegtran-rotate-lossless
diff options
context:
space:
mode:
authorPatrick Simianer <p@simianer.de>2014-08-10 11:19:38 +0100
committerPatrick Simianer <p@simianer.de>2014-08-10 11:19:38 +0100
commit5869505d64c04c536bdcd71a197ade918c36bf1c (patch)
tree6af5232a9f2e058f15230a370a960f89871a2b74 /jpegtran-rotate-lossless
init
Diffstat (limited to 'jpegtran-rotate-lossless')
-rwxr-xr-xjpegtran-rotate-lossless37
1 files changed, 37 insertions, 0 deletions
diff --git a/jpegtran-rotate-lossless b/jpegtran-rotate-lossless
new file mode 100755
index 0000000..77a0949
--- /dev/null
+++ b/jpegtran-rotate-lossless
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+
+function usage {
+ echo 'Usage: jpegtran-rotate-lossless.sh <90|180|270> <file>'
+ exit 1
+}
+
+ROTATION=$1
+FILE=$2
+
+if [ $# -ne 2 ]; then
+ usage
+fi
+
+case $ROTATION in
+ 90|180|270)
+ true ;;
+ *)
+ usage ;;
+esac
+
+
+jpegtran -rotate $ROTATION -trim -copy all $FILE > $FILE-rotate
+if [ $? -ne 0 ]; then
+ echo 'jpegtran-rotate-lossless.sh: jpegtran failed'
+ exit 1
+fi
+
+mv $FILE-rotate $FILE
+if [ $? -ne 0 ]; then
+ 'jpegtran-rotate-lossless.sh: mv failed'
+ exit 1
+fi
+
+exit 0
+