Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ImageUploader < CarrierWave::Uploader::Base
- include CarrierWave::MiniMagick
- ...
- version :t do
- process :cropper
- process :resize_to_fill => [75, 75]
- end
- ...
- def cropper
- manipulate! do |img|
- img = img.crop "#{model.crop_x}x#{model.crop_y}+#{model.crop_w}+#{model.crop_h}"
- img
- end
- end
- end
- process :cropper
- def cropper
- manipulate! do |img|
- if model.crop_x.blank?
- image = MiniMagick::Image.open(current_path)
- model.crop_w = (image[:width] * 0.8).to_i
- model.crop_y = (image[:height] * 0.8).to_i
- model.crop_x = (image[:width] * 0.1).to_i
- model.crop_y = (image[:height] * 0.1).to_i
- end
- img.crop "#{model.crop_w}x#{model.crop_h}+#{model.crop_x}+#{model.crop_y}"
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement