Mercurial > geeqie
annotate plugins/rotate/geeqie-rotate @ 1794:155a6252ceaa
Brazilian Portuguese translation was updated.
Thanks to Sergio Cipolla.
References:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=567824
author | zas_ |
---|---|
date | Tue, 02 Feb 2010 20:21:11 +0000 |
parents | f549702f7b41 |
children |
rev | line source |
---|---|
1707 | 1 #!/bin/sh |
1647 | 2 |
3 # This is a helper script that rotate image files according to the metadata | |
4 # requirements: ImageMagick, exiftran, exiv2 | |
5 | |
6 GQ_METADATA_DIR="$HOME/.local/share/geeqie/metadata" | |
1616
5b36a6ff55ae
Add .desktop files to restore lossless jpeg rotation via editors.
zas_
parents:
diff
changeset
|
7 |
1647 | 8 rotate() |
9 { | |
10 ext=`echo "${1##*.}" |tr "[:upper:]" "[:lower:]"` | |
11 [ "x$ext" == "x" ] && return 1 #no extension | |
12 | |
13 gq_metadata="$GQ_METADATA_DIR/$1.gq.xmp" | |
14 if [ -f "$gq_metadata" ]; then | |
15 gq_orientation=`exiv2 -PXkv "$gq_metadata"|grep Xmp.tiff.Orientation|sed -e "s|Xmp.tiff.Orientation *||"` | |
16 else | |
17 gq_orientation= | |
18 fi | |
1616
5b36a6ff55ae
Add .desktop files to restore lossless jpeg rotation via editors.
zas_
parents:
diff
changeset
|
19 |
1647 | 20 case "$ext" in |
21 jpg|jpeg) | |
22 [ -n "$gq_orientation" ] && exiv2 -M "set Exif.Image.Orientation $gq_orientation" "$1" | |
23 if exiftran -aip "$1" ; then | |
24 # exiftran ignores xmp, set it manually | |
25 exiv2 -M "set Xmp.tiff.Orientation 1" "$1" | |
26 #http://dev.exiv2.org/issues/show/639 | |
27 [ -n "$gq_orientation" ] && exiv2 -M "set Xmp.tiff.Orientation 1" \ | |
28 -M "set Exif.Image.Orientation 1" "$gq_metadata" | |
29 return 0 | |
30 fi | |
31 ;; | |
32 | |
33 tif|tiff|png) | |
34 [ -n "$gq_orientation" ] && exiv2 -M "set Exif.Image.Orientation $gq_orientation" "$1" | |
35 if mogrify -auto-orient "$1" ; then | |
36 # mogrify ignores xmp, set it manually | |
37 exiv2 -M "set Xmp.tiff.Orientation 1" "$1" | |
38 #http://dev.exiv2.org/issues/show/639 | |
39 [ -n "$gq_orientation" ] && exiv2 -M "set Xmp.tiff.Orientation 1" \ | |
40 -M "set Exif.Image.Orientation 1" "$gq_metadata" | |
41 return 0 | |
42 fi | |
43 ;; | |
44 *) #not supported | |
45 return 0 | |
46 ;; | |
47 esac | |
48 } | |
1616
5b36a6ff55ae
Add .desktop files to restore lossless jpeg rotation via editors.
zas_
parents:
diff
changeset
|
49 |
1749
f549702f7b41
added possibility to use geeqie-rotate as a standalone script
nadvornik
parents:
1707
diff
changeset
|
50 get_sidecars= |
f549702f7b41
added possibility to use geeqie-rotate as a standalone script
nadvornik
parents:
1707
diff
changeset
|
51 if [ "x$1" == "x-g" ] ; then |
f549702f7b41
added possibility to use geeqie-rotate as a standalone script
nadvornik
parents:
1707
diff
changeset
|
52 get_sidecars=yes |
f549702f7b41
added possibility to use geeqie-rotate as a standalone script
nadvornik
parents:
1707
diff
changeset
|
53 shift |
f549702f7b41
added possibility to use geeqie-rotate as a standalone script
nadvornik
parents:
1707
diff
changeset
|
54 fi |
f549702f7b41
added possibility to use geeqie-rotate as a standalone script
nadvornik
parents:
1707
diff
changeset
|
55 |
1647 | 56 # iterate over files on commandline |
1616
5b36a6ff55ae
Add .desktop files to restore lossless jpeg rotation via editors.
zas_
parents:
diff
changeset
|
57 for file in "$@" ; do |
1749
f549702f7b41
added possibility to use geeqie-rotate as a standalone script
nadvornik
parents:
1707
diff
changeset
|
58 if [ -n "$get_sidecars" ] ; then |
f549702f7b41
added possibility to use geeqie-rotate as a standalone script
nadvornik
parents:
1707
diff
changeset
|
59 # we got only one file for each group, typically the main one |
f549702f7b41
added possibility to use geeqie-rotate as a standalone script
nadvornik
parents:
1707
diff
changeset
|
60 # get the sidecars: |
f549702f7b41
added possibility to use geeqie-rotate as a standalone script
nadvornik
parents:
1707
diff
changeset
|
61 geeqie -r --get-sidecars:"$file" |while read sidecar ; do |
f549702f7b41
added possibility to use geeqie-rotate as a standalone script
nadvornik
parents:
1707
diff
changeset
|
62 # the main file is included in the sidecar file list, no special handling is required |
f549702f7b41
added possibility to use geeqie-rotate as a standalone script
nadvornik
parents:
1707
diff
changeset
|
63 rotate "$sidecar" |
f549702f7b41
added possibility to use geeqie-rotate as a standalone script
nadvornik
parents:
1707
diff
changeset
|
64 done |
f549702f7b41
added possibility to use geeqie-rotate as a standalone script
nadvornik
parents:
1707
diff
changeset
|
65 else |
f549702f7b41
added possibility to use geeqie-rotate as a standalone script
nadvornik
parents:
1707
diff
changeset
|
66 rotate "$file" |
f549702f7b41
added possibility to use geeqie-rotate as a standalone script
nadvornik
parents:
1707
diff
changeset
|
67 fi |
1616
5b36a6ff55ae
Add .desktop files to restore lossless jpeg rotation via editors.
zas_
parents:
diff
changeset
|
68 done |
1647 | 69 |