This is the best I can do. There is probably an easier way to do this, but this is my hack:
Here is my POST controller action when transmitting crop information:
def update_crop @user = User.find(current_user.id) @user.crop(params[:x].to_i, params[:y].to_i, params[:h].to_i, params[:w].to_i) redirect_to(profile_path, :notice => 'Your profile and avatar was successfully updated.') end
Here's a way to add a user that contains an avatar image downloader to the model:
def crop(x, y, h, w) image = Magick::ImageList.new(avatar.current_path) cropped_image = image.crop(x, y, h, w) cropped_image.write(avatar.current_path) avatar.recreate_versions! end
It basically just greets the current one, overwrites it, and then tells Carrierwave to create
Fire emblem
source share