Mercurial > geeqie
annotate plugins/rotate/geeqie-rotate @ 1723:0e235874877e
write metadata before another opeation
- this is implemented for copy and external editor
- the unsaved metadata should survive operations like move or rename
- saving metadata before delete is pointless
author | nadvornik |
---|---|
date | Tue, 25 Aug 2009 21:30:50 +0000 |
parents | a15dc91173b4 |
children | f549702f7b41 |
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 |
1647 | 50 # iterate over files on commandline |
1616
5b36a6ff55ae
Add .desktop files to restore lossless jpeg rotation via editors.
zas_
parents:
diff
changeset
|
51 for file in "$@" ; do |
1647 | 52 # we got only one file for each group, typically the main one |
53 # get the sidecars: | |
54 geeqie -r --get-sidecars:"$file" |while read sidecar ; do | |
55 # the main file is included in the sidecar file list, no special handling is required | |
56 rotate "$sidecar" | |
57 done | |
1616
5b36a6ff55ae
Add .desktop files to restore lossless jpeg rotation via editors.
zas_
parents:
diff
changeset
|
58 done |
1647 | 59 |