Use mask file to clip images with minimagick.
Add this line to your application's Gemfile:
gem 'mini_magick_clip'
And then execute:
$ bundle
Or install it yourself as:
$ gem install mini_magick_clip
Carrierwave example:
class AvatarUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
include MiniMagickClip
process convert: 'png'
version :thumb do
process resize_to_fill: [210, 210]
process mask: Rails.root.join('app/uploaders/t-shirt-mask.png')
end
def filename
if original_filename
[
model.username,
"png"
].join(".")
end
end
end
Bug reports and pull requests are welcome on GitHub at https://github.com/sharshenov/minimagick-clip.
The gem is available as open source under the terms of the MIT License.