module Pushfile::Resize
Public Instance Methods
resize!()
click to toggle source
Resize
file. Keeping aspect ratio.
# File lib/pushfile/resize.rb, line 7 def resize! begin image = MiniMagick::Image.open(@file.path) image.resize("#{@width}x#{@height}") rescue # Pass on any error else image.write(@file.path) rescue nil end end
thumbnail!()
click to toggle source
Create thumbnail, same name but with _thumb at the end
# File lib/pushfile/resize.rb, line 19 def thumbnail! begin image = MiniMagick::Image.open(@file.path) image.resize("#{Pushfile.settings[:images][:thumb][:width]}x") rescue @thumb = nil else t = @name.split('.'); ext = t.pop @thumb = t.join(".").concat("_thumb.#{ext}") image.write("/tmp/#{@thumb}") rescue @thumb = nil end end