RMagick replacement which uses ImageMagick directly by constructing chainable commands
Ruby
Pull request Compare This branch is 12 commits behind fabien:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
spec
tasks
.gitignore
History.txt
License.txt
Manifest.txt
README
Rakefile
VERSION
setup.rb

README

ImMagick
========

RMagick replacement which uses ImageMagick directly by constructing chainable
commands with value placeholders. It basically delegates to the command-line
tools, so constructing commands is similar to how you would work with those.
The code itself is nothing fancy, it just gets the job done by providing a
simple DSL-like construct.

Here are a couple of examples:

cmd = ImMagick::convert.from(:source).resize(:w, :h).grayscale.to('thumbs/thumb-%03d.jpg')
cmd.run(:source => 'images/logo.png', :w => 100, :h => 100).save(7) # => thumbs/thumb-007.jpg

---

img = ImMagick::Image.file('images/logo.png')
img.crop_resized(200, 200, :south)

puts img.inspect
=> "images/logo.png -resize 200x207 -gravity south -crop 200x200+0+0 +repage"

---

img = ImMagick::Image.file('images/logo.png')
img.crop_resized(:w, :h, :g) # width, height, gravity placeholders

puts img.inspect(:w => 200, :h => 300, :g => :south) 
=> "images/logo.png -resize 291x300 -gravity south -crop 200x300+0+0 +repage"

img.save('output/crop-resized-img.jpg', :w => 200, :h => 300, :g => :south)

---

cmd = ImMagick::convert do |c|
  c.background(:black)
  c.fill(:white)
  c.font('./unionbd.ttf')
  c.pointsize(40)
  c.size('300x')
  c.gravity('west')
  c.caption(:placeholder)
end

puts cmd.inspect(:placeholder => 'FooBar')
=> "-background black -fill white -font ./unionbd.ttf -pointsize 40 -size 300x -gravity west caption:'FooBar'"

cmd.run(:placeholder => 'FooBar').save('output/foo-bar.png')