Module: Gnome::Wallpaper::Changer::Resizer::ClassMethods

Included in:
Gnome::Wallpaper::Changer::Resizer
Defined in:
lib/gnome-wallpaper-changer/resizer.rb

Instance Method Summary collapse

Instance Method Details

#resize(path) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/gnome-wallpaper-changer/resizer.rb', line 9

def resize path
  thumb = Digest::SHA1.hexdigest(path) + File.extname(path)
  thumb_path = THUMB_DIR + '/' + thumb
  if !File.exists?( thumb_path )
    File.open path, "r" do |io|
      FastImage.resize io, 0, 50, :outfile => thumb_path
    end
  end
  thumb_path
rescue FastImage::ImageFetchFailure => e
  puts "Could not open file: #{path} (#{e})"
  nil
end