correctly compare sizes as numbers
authorgc <gc>
Sun, 8 May 2005 22:53:42 +0000 (22:53 +0000)
committergc <gc>
Sun, 8 May 2005 22:53:42 +0000 (22:53 +0000)
bin/booh-backend
lib/booh/booh-lib.rb

index 4120e0ea8b3f9ef91e04596d29542f73dde1314f..aa4ce337c5664cc2b8c6c1c5fc177b3dcda1841c 100755 (executable)
@@ -342,7 +342,7 @@ end
 
 def img_element(fullpath)
     if size = get_image_size(fullpath)
-        sizespec = 'width="' + size[:x] + '" height="' + size[:y] + '"'
+        sizespec = 'width="#{size[:x]}" height="#{size[:y]}"'
     else
         sizespec = ''
     end
index 07ad6f66024096bb6b09ca912c1e6ed10919c125..94107f79982ca0e8f10cd735032f66aafba019b6 100644 (file)
@@ -165,7 +165,7 @@ module Booh
 
     def get_image_size(fullpath)
         if `identify '#{fullpath}'` =~ / JPEG (\d+)x(\d+) /
-            return { :x => $1, :y => $2 }
+            return { :x => $1.to_i, :y => $2.to_i }
         else
             return nil
         end
@@ -238,8 +238,8 @@ module Booh
                     #- don't resize if image is already smaller than destination size
                     if size = get_image_size(orig)
                         dest['size'] =~ /(\d+)x(\d+)/
-                        if (rotate == "90" || rotate == "270") && (size[:x] < $2 || size[:y] < $1) ||
-                                                                   size[:x] < $1 || size[:y] < $2
+                        if (rotate == "90" || rotate == "270") && (size[:x] < $2.to_i || size[:y] < $1.to_i) ||
+                                                                   size[:x] < $1.to_i || size[:y] < $2.to_i
                             cmd = "#{$convert} #{convert_options} '#{orig}' '#{dest['filename']}'"
                         end
                     end