I am using carrierwave with minimagick to upload an image and crop it to a square. However I get the following error:
undefined method 'manipulate!' for #<Class:0x692db10>
it seems to make no sense, as i have included the correct class, and that part works fine. Heres my current uploader class.
class ImageUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
@@sizes = {
"2000" => 2048,
"1500" => 1500,
"1000" => 1024,
"500" => 512,
"250" => 256,
"100" => 128
}
storage :file
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
version :square do
manipulate! do |img|
size = img.dimensions.min
end
process resize_to_fill: [size, size]
end
end
to be clear, we are talking about the :square
version. Does anyone have any idea what could be wrong?
It seems manipulate!
belongs to RMagick
adapter, for MiniMagick you should use something like mogrify
.
Indeed, there's such method, but you're trying to use it in a class scope, while it's an instance method. There's a bunch of useful class methods you can use already.
If you still need manipulate!
, make something like this:
process :radial_blur => 10
def radial_blur(amount)
manipulate! do |img|
img.radial_blur(amount)
img = yield(img) if block_given?
img
end
end