- use exif to rotate portrait taken photos
[booh] / booh
diff --git a/booh b/booh
index 409effad5e1ad20a0d9c99c350bb7868b2f560a7..3e8e32775c447b8a6b3cd521fb861a7f5e85880f 100755 (executable)
--- a/booh
+++ b/booh
@@ -152,9 +152,9 @@ def walk_source_dir
     `find #{$source} -type d`.each { |dir|
         dir.chomp!
         msg 2, "Examining #{dir}..."
-        images = Dir["#{dir}/*.{jpg,jpeg,gif,bmp,png}"]
+        images = Dir["#{dir}/*.{jpg,JPG,jpeg,JPEG,gif,GIF,bmp,BMP,png,PNG}"]
         msg 2, "\t#{images.length} images"
-        videos = Dir["#{dir}/*.{mov,avi,mpg,mpeg}"]
+        videos = Dir["#{dir}/*.{mov,MOV,avi,AVI,mpg,MPG,mpeg,MPEG,wmv,WMV,asx,ASX}"]
         msg 2, "\t#{videos.length} videos"
         
         dest_dir = dir.sub(/^#{$source}/, $dest)
@@ -167,7 +167,15 @@ def walk_source_dir
                            sub(/\.[^\.]+$/, '') + '-704.jpg'
             final_images << File.basename(dest_img)
             if !File.exists?(dest_img)
-                sys "#{$convert} -geometry 704x528 #{img} #{dest_img}"
+                convert_options = ''
+                orientation = `exif #{img}`.detect { |line| line =~ /^Orientation/ }
+                if orientation =~ /right - top/
+                    convert_options += '-rotate 90 '
+                end
+                if orientation =~ /left - bottom/
+                    convert_options += '-rotate -90 '
+                end
+                sys "#{$convert} #{convert_options}-geometry 704x528 #{img} #{dest_img}"
             end
         }