$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
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
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