From: gc Date: Sun, 8 Jul 2007 12:58:34 +0000 (+0000) Subject: use Gdk::Pixbuf#get_file_info for obtaining the dimensions of the picture, its faaaster X-Git-Tag: 0.9.0~209 X-Git-Url: http://git.zarb.org/?p=booh;a=commitdiff_plain;h=c6d5ae4835b98416a3e06692c057e902309224d5;hp=a203acd0455a7c2776416bd214537d7fdd18b9ce use Gdk::Pixbuf#get_file_info for obtaining the dimensions of the picture, its faaaster --- diff --git a/lib/booh/booh-lib.rb b/lib/booh/booh-lib.rb index 50b45eb..086f8a7 100644 --- a/lib/booh/booh-lib.rb +++ b/lib/booh/booh-lib.rb @@ -227,14 +227,15 @@ module Booh $sizes_cache = {} end if $sizes_cache[fullpath].nil? - #- identify is slow, try with gdk if available (4ms vs 35ms) + #- identify is slow, try with gdk if available (negligible vs 35ms) if $no_gtk2 if `identify '#{fullpath}'` =~ / JPEG (\d+)x(\d+) / $sizes_cache[fullpath] = { :x => $1.to_i, :y => $2.to_i } end else - if pxb = Gdk::Pixbuf.new(fullpath) - $sizes_cache[fullpath] = { :x => pxb.width, :y => pxb.height } + format, width, height = Gdk::Pixbuf.get_file_info(fullpath) + if width + $sizes_cache[fullpath] = { :x => width, :y => height } end end end @@ -271,8 +272,9 @@ module Booh else return 0 end - size = get_image_size(filename) + #- remove rotate if image is obviously already in portrait (situation can come from gthumb) + size = get_image_size(filename) if size && size[:x] < size[:y] return 0 else @@ -283,7 +285,7 @@ module Booh def rotate_pixbuf(pixbuf, angle) return pixbuf.rotate(angle == 90 ? Gdk::Pixbuf::ROTATE_CLOCKWISE : angle == 180 ? Gdk::Pixbuf::ROTATE_UPSIDEDOWN : - angle == 270 ? Gdk::Pixbuf::ROTATE_COUNTERCLOCKWISE : + (angle == 270 || angle == -90) ? Gdk::Pixbuf::ROTATE_COUNTERCLOCKWISE : Gdk::Pixbuf::ROTATE_NONE) end