add gamma correction suggested by coni
[booh] / lib / booh / booh-lib.rb
index 1121c956e2098456d562fc12ed26585c0eacf62a..35a3b36df353cad96cf1b9b54104705e25df4a73 100644 (file)
@@ -287,6 +287,14 @@ module Booh
                         orig = neworig
                     end
                 end
+                if gammacorrect = felem.attributes["#{attributes_prefix}gamma-correction"]
+                    neworig = "#{dest_dir}/#{File.basename(orig)}-gammacorrect#{gammacorrect}.jpg"
+                    cmd = "booh-gamma-correction '#{orig}' '#{neworig}' #{gammacorrect}"
+                    sys(cmd)
+                    if File.exists?(neworig)
+                        orig = neworig
+                    end
+                end
                 rotate = felem.attributes["#{attributes_prefix}rotate"]
                 if !rotate
                     felem.add_attribute("#{attributes_prefix}rotate", rotate = guess_rotate(orig).to_i)
@@ -381,6 +389,16 @@ module Booh
                             end
                         end
                     end
+                    if felem && gammacorrect = felem.attributes["#{attributes_prefix}gamma-correction"]
+                        if gammacorrect.to_f != 0
+                            neworig = "#{dest_dir}/#{orig_base}-gammacorrect#{gammacorrect}.jpg"
+                            cmd = "booh-gamma-correction '#{orig_image}' '#{neworig}' #{gammacorrect}"
+                            sys(cmd)
+                            if File.exists?(neworig)
+                                orig_image = neworig
+                            end
+                        end
+                    end
                 end
                 if !File.exists?(dest['filename'])
                     sys("#{$convert} #{convert_options}-size #{dest['size']} -resize #{dest['size']} '#{orig_image}' '#{dest['filename']}'")