Revision: 1746
          http://geeqie.svn.sourceforge.net/geeqie/?rev=1746&view=rev
Author:   nadvornik
Date:     2009-06-15 19:13:45 +0000 (Mon, 15 Jun 2009)

Log Message:
-----------
improved rotation script

- applies the orientation from metadata
- uses exiftran for jpeg an ImageMagick for other files

Modified Paths:
--------------
    trunk/plugins/rotate/Makefile.am
    trunk/plugins/rotate/geeqie-rotate

Added Paths:
-----------
    trunk/plugins/rotate/rotate.desktop

Removed Paths:
-------------
    trunk/plugins/rotate/rotate180.desktop
    trunk/plugins/rotate/rotate270.desktop
    trunk/plugins/rotate/rotate90.desktop

Modified: trunk/plugins/rotate/Makefile.am
===================================================================
--- trunk/plugins/rotate/Makefile.am    2009-06-14 08:49:39 UTC (rev 1745)
+++ trunk/plugins/rotate/Makefile.am    2009-06-15 19:13:45 UTC (rev 1746)
@@ -1,7 +1,7 @@
 dist_pkglib_SCRIPTS = geeqie-rotate
 
 qq_desktopdir = $(pkgdatadir)/applications
-qq_desktop_DATA = rotate90.desktop rotate180.desktop rotate270.desktop
+qq_desktop_DATA = rotate.desktop
 
 EXTRA_DIST = $(qq_desktop_DATA)
 

Modified: trunk/plugins/rotate/geeqie-rotate
===================================================================
--- trunk/plugins/rotate/geeqie-rotate  2009-06-14 08:49:39 UTC (rev 1745)
+++ trunk/plugins/rotate/geeqie-rotate  2009-06-15 19:13:45 UTC (rev 1746)
@@ -1,15 +1,59 @@
-#!/bin/sh
+#!/bin/bash -x
 
-# This is a helper script that rotate jpeg files using jpegtran
+# This is a helper script that rotate image files according to the metadata
+# requirements: ImageMagick, exiftran, exiv2
 
-rotation=$1
-shift
+GQ_METADATA_DIR="$HOME/.local/share/geeqie/metadata"
 
+rotate()
+{
+    ext=`echo "${1##*.}" |tr "[:upper:]" "[:lower:]"`
+    [ "x$ext" == "x" ] && return 1 #no extension
+
+    gq_metadata="$GQ_METADATA_DIR/$1.gq.xmp"
+    if [ -f "$gq_metadata" ]; then
+       gq_orientation=`exiv2 -PXkv "$gq_metadata"|grep 
Xmp.tiff.Orientation|sed -e "s|Xmp.tiff.Orientation *||"`
+    else
+       gq_orientation=
+    fi
+
+    case "$ext" in
+       jpg|jpeg) 
+               [ -n "$gq_orientation" ] && exiv2 -M "set 
Exif.Image.Orientation $gq_orientation" "$1"
+               if exiftran -aip "$1" ; then
+                   # exiftran ignores xmp, set it manually
+                   exiv2 -M "set Xmp.tiff.Orientation 1" "$1"
+                   #http://dev.exiv2.org/issues/show/639
+                   [ -n "$gq_orientation" ] && exiv2 -M "set 
Xmp.tiff.Orientation 1" \
+                                                     -M "set 
Exif.Image.Orientation 1" "$gq_metadata"
+                   return 0
+               fi
+               ;;
+       
+       tif|tiff|png)
+               [ -n "$gq_orientation" ] && exiv2 -M "set 
Exif.Image.Orientation $gq_orientation" "$1"
+               if mogrify -auto-orient "$1" ; then
+                   # mogrify ignores xmp, set it manually
+                   exiv2 -M "set Xmp.tiff.Orientation 1" "$1"
+                   #http://dev.exiv2.org/issues/show/639
+                   [ -n "$gq_orientation" ] && exiv2 -M "set 
Xmp.tiff.Orientation 1" \
+                                                     -M "set 
Exif.Image.Orientation 1" "$gq_metadata"
+                   return 0
+               fi
+               ;;
+       *)      #not supported
+               return 0
+               ;;
+    esac
+}
+
+# iterate over files on commandline
 for file in "$@" ; do
-       tmp="$file".$$
-       if jpegtran -rotate "$rotation" -copy all -outfile "$tmp" "$file"; then
-               mv -f "$tmp" "$file";
-       else
-               rm -f "$tmp";
-       fi
+    # we got only one file for each group, typically the main one
+    # get the sidecars:
+    geeqie -r --get-sidecars:"$file" |while read sidecar ; do
+       # the main file is included in the sidecar file list, no special 
handling is required
+       rotate "$sidecar"
+    done
 done
+

Added: trunk/plugins/rotate/rotate.desktop
===================================================================
--- trunk/plugins/rotate/rotate.desktop                         (rev 0)
+++ trunk/plugins/rotate/rotate.desktop 2009-06-15 19:13:45 UTC (rev 1746)
@@ -0,0 +1,19 @@
+[Desktop Entry]
+Version=1.0
+Type=Application
+Name=Apply the orientation to image content
+
+# call the helper script
+Exec=geeqie-rotate %f
+
+# Desktop files that are usable only in Geeqie should be marked like this:
+Categories=X-Geeqie;
+OnlyShowIn=X-Geeqie;
+
+# Show in menu "Edit/Orientation"
+X-Geeqie-Menu-Path=EditMenu/OrientationMenu
+
+# It can be made verbose
+# X-Geeqie-Verbose=true
+
+MimeType=image/jpeg;image/png;image/tiff;

Deleted: trunk/plugins/rotate/rotate180.desktop
===================================================================
--- trunk/plugins/rotate/rotate180.desktop      2009-06-14 08:49:39 UTC (rev 
1745)
+++ trunk/plugins/rotate/rotate180.desktop      2009-06-15 19:13:45 UTC (rev 
1746)
@@ -1,20 +0,0 @@
-[Desktop Entry]
-Version=1.0
-Type=Application
-Name=Rotate 180 degrees
-Name[fr]=Rotation 180°
-
-# call the helper script
-Exec=geeqie-rotate 180 %f
-
-# Desktop files that are usable only in Geeqie should be marked like this:
-Categories=X-Geeqie;
-OnlyShowIn=X-Geeqie;
-
-# Show in menu "File"
-X-Geeqie-Menu-Path=FileMenu/FileOpsSection
-
-# It can be made verbose
-#X-Geeqie-Verbose=true
-
-MimeType=image/jpeg;image/jpg;

Deleted: trunk/plugins/rotate/rotate270.desktop
===================================================================
--- trunk/plugins/rotate/rotate270.desktop      2009-06-14 08:49:39 UTC (rev 
1745)
+++ trunk/plugins/rotate/rotate270.desktop      2009-06-15 19:13:45 UTC (rev 
1746)
@@ -1,20 +0,0 @@
-[Desktop Entry]
-Version=1.0
-Type=Application
-Name=Rotate 90 degrees counterclockwise
-Name[fr]=Rotation 90° vers la gauche
-
-# call the helper script
-Exec=geeqie-rotate 270 %f
-
-# Desktop files that are usable only in Geeqie should be marked like this:
-Categories=X-Geeqie;
-OnlyShowIn=X-Geeqie;
-
-# Show in menu "File"
-X-Geeqie-Menu-Path=FileMenu/FileOpsSection
-
-# It can be made verbose
-#X-Geeqie-Verbose=true
-
-MimeType=image/jpeg;image/jpg;

Deleted: trunk/plugins/rotate/rotate90.desktop
===================================================================
--- trunk/plugins/rotate/rotate90.desktop       2009-06-14 08:49:39 UTC (rev 
1745)
+++ trunk/plugins/rotate/rotate90.desktop       2009-06-15 19:13:45 UTC (rev 
1746)
@@ -1,20 +0,0 @@
-[Desktop Entry]
-Version=1.0
-Type=Application
-Name=Rotate 90 degrees clockwise
-Name[fr]=Rotation 90° vers la droite
-
-# call the helper script
-Exec=geeqie-rotate 90 %f
-
-# Desktop files that are usable only in Geeqie should be marked like this:
-Categories=X-Geeqie;
-OnlyShowIn=X-Geeqie;
-
-# Show in menu "File"
-X-Geeqie-Menu-Path=FileMenu/FileOpsSection
-
-# It can be made verbose
-#X-Geeqie-Verbose=true
-
-MimeType=image/jpeg;image/jpg;


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Geeqie-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geeqie-svn

Reply via email to