Skip to content

Instantly share code, notes, and snippets.

@sled
Last active December 17, 2015 21:19
Show Gist options
  • Save sled/95dbaec1834f533eb172 to your computer and use it in GitHub Desktop.
Save sled/95dbaec1834f533eb172 to your computer and use it in GitHub Desktop.

Revisions

  1. sled revised this gist Dec 17, 2015. 1 changed file with 7 additions and 0 deletions.
    7 changes: 7 additions & 0 deletions refile_rotate.rb
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,11 @@
    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|
  2. sled created this gist Dec 17, 2015.
    13 changes: 13 additions & 0 deletions refile_rotate.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    Refile::MiniMagick.prepend Module.new {
    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
    }