Last active
December 3, 2023 03:05
-
-
Save umate/7588344 to your computer and use it in GitHub Desktop.
CarrierWave gaussian blur filter using MiniMagick
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ImageUploader < CarrierWave::Uploader::Base | |
include CarrierWave::MiniMagick | |
version :blurred do | |
process :blur | |
end | |
def blur(radius=16) | |
manipulate! do |img| | |
original_path = img.path | |
temp_image_path = File.join(Rails.root, 'public', cache_dir, "/blurred_#{File.basename(original_path)}") | |
command = "convert #{original_path} -blur 0x#{radius} #{temp_image_path}" | |
system(command) | |
MiniMagick::Image.open(temp_image_path) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
to delete /tmp/blurred_....
replace
with