Skip to content

Instantly share code, notes, and snippets.

@kvnsmth
Created October 15, 2010 15:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kvnsmth/628432 to your computer and use it in GitHub Desktop.
Save kvnsmth/628432 to your computer and use it in GitHub Desktop.
Just some code that I threw together to play around with CarrierWave's image manipulation
require 'rubygems'
require 'carrierwave'
require 'fileutils'
# needed for the RMagick module in CarrierWave
def current_path
@current_path
end
include CarrierWave::RMagick
original_path = "/Users/kevinsmith/Desktop/carrierwave/images"
modified_path = "/Users/kevinsmith/Desktop/carrierwave/modified"
w = 262
h = 262
Dir.chdir(original_path)
Dir['*'].each do |f|
FileUtils.cp(File.join(Dir.pwd, f), modified_path)
@current_path = File.join(modified_path, f)
#resize_to_fit(w, h)
resize_to_fill(w, h, ::Magick::NorthWestGravity)
#resize_and_pad(w, h, :transparent, ::Magick::CenterGravity)
#resize_to_limit(w, h)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment