summaryrefslogtreecommitdiff
path: root/jpegtran_rotate_lossless
blob: f876e10104482efb1f7de4a3cb54f7685b3dd8a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/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