Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 206285 | Differences between
and this patch

Collapse All | Expand All

(-)exifautotran/exifautotran (-8 / +33 lines)
Lines 3-17 Link Here
3
#
3
#
4
# Transforms Exif files so that Orientation becomes 1
4
# Transforms Exif files so that Orientation becomes 1
5
#
5
#
6
7
trap "if test -n \"\$tempfile\"; then rm -f \"\$tempfile\"; fi" INT QUIT TERM
8
9
preserve_timestamps=""
10
6
for i
11
for i
7
do
12
do
8
 case $i in
13
 case "$i" in
14
 -p|--pretend) preserve_timestamps="yes"; continue;;
9
 -v|--version) echo "exifautotran"; exit 0;;
15
 -v|--version) echo "exifautotran"; exit 0;;
10
 -h|--help) 
16
 -h|--help) 
11
             cat <<EOF
17
             cat <<EOF
12
exifautotran [list of files]
18
exifautotran [-p] [list of files]
13
19
14
Transforms Exif files so that Orientation becomes 1
20
Transforms Exif files so that Orientation becomes 1
21
22
 -p, --preserve		Preserve modification time of each file.
15
EOF
23
EOF
16
             exit 0;;
24
             exit 0;;
17
 esac
25
 esac
Lines 28-41 Link Here
28
 *) transform="";;
36
 *) transform="";;
29
 esac
37
 esac
30
 if test -n "$transform"; then
38
 if test -n "$transform"; then
31
  echo Executing: jpegtran -copy all $transform $i >&2
39
  tempfile=`mktemp` || {
32
  jpegtran -copy all $transform "$i" > tempfile
40
    echo "Failed to create temporary file" >&2
41
    exit 1;
42
  }
43
  echo "Executing: jpegtran -copy all $transform $i" >&2
44
  jpegtran -copy all $transform "$i" > "$tempfile"
33
  if test $? -ne 0; then
45
  if test $? -ne 0; then
34
   echo Error while transforming $i - skipped. >&2
46
   echo "Error while transforming $i - skipped." >&2
47
   rm "$tempfile"
35
  else
48
  else
36
   rm "$i"
49
   jpegexiforient -1 "$tempfile" > /dev/null
37
   mv tempfile "$i"
50
   if test -n "$preserve_timestamps"; then
38
   jpegexiforient -1 "$i" > /dev/null
51
     touch -r "$i" "$tempfile"
52
   fi
53
   # read original permissions for setting later
54
   original_mode=`stat -c %a "$i"`
55
   mv "$tempfile" "$i" || {
56
     echo "Failed to update $i - skipped." >&2
57
     rm "$tempfile"
58
     continue
59
   }
60
   # set original permissions only after moving the file back,
61
   # to avoid setting potentially unsafe permissions on the file
62
   # while it's in /tmp, where it could be accessed by anyone
63
   chmod "$original_mode" "$i"
39
  fi
64
  fi
40
 fi
65
 fi
41
done
66
done

Return to bug 206285