Last active
December 17, 2015 21:19
puts this under app/config/initializers/refile_rotate.rb
This file contains hidden or 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
Refile::MiniMagick.prepend Module.new { | |
define_method('rotate') do |img, angle=0| | |
img.combine_options do |cmd| | |
yield cmd if block_given? | |
cmd.rotate angle | |
end | |
end | |
define_method('fill_rotate') do |img, width, height, angle=0, gravity="Center"| | |
# We use `convert` to work around GraphicsMagick's absence of "gravity" | |
::MiniMagick::Tool::Convert.new do |cmd| | |
yield cmd if block_given? | |
cmd.rotate angle | |
cmd.resize "#{width}x#{height}^" | |
cmd.gravity gravity | |
cmd.extent "#{width}x#{height}" | |
cmd.merge! [img.path, img.path] | |
end | |
end | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment