public
Description: mini replacement for RMagick
Homepage: http://mini_magick.rubyforge.org/
Clone URL: git://github.com/probablycorey/mini_magick.git
name age message
file .gitignore Wed May 27 10:08:15 -0700 2009 added jewler support [probablycorey]
file MIT-LICENSE Wed Mar 05 17:36:02 -0800 2008 first! [for-lesbians]
file README.rdoc Tue May 26 18:04:57 -0700 2009 gobbled up a bunch of remvees patches [probablycorey]
file Rakefile Wed May 27 10:08:15 -0700 2009 added jewler support [probablycorey]
file VERSION Wed May 27 10:08:15 -0700 2009 added jewler support [probablycorey]
directory lib/ Wed Aug 05 11:15:28 -0700 2009 run_command was using a wrong regular expressio... [halfbyte]
file mini_magick.gemspec Wed May 27 10:10:24 -0700 2009 Regenerated gemspec for version 1.2.5 [probablycorey]
directory test/ Wed Aug 05 11:15:28 -0700 2009 run_command was using a wrong regular expressio... [halfbyte]
README.rdoc

MiniMagick

A ruby wrapper for ImageMagick command line.

Why?

I was using RMagick and loving it, but it was eating up huge amounts of memory. A simple script like this…

  Magick::read("image.jpg") do |f|
    f.write("manipulated.jpg")
  end

…would use over 100 Megs of Ram. On my local machine this wasn’t a problem, but on my hosting server the ruby apps would crash because of their 100 Meg memory limit.

Solution!

Using MiniMagick the ruby processes memory remains small (it spawns ImageMagick’s command line program mogrify which takes up some memory as well, but is much smaller compared to RMagick)

MiniMagick gives you access to all the commandline options ImageMagick has (Found here www.imagemagick.org/script/mogrify.php)

Examples

Want to make a thumbnail from a file…

  image = MiniMagick::Image.from_file("input.jpg")
  image.resize "100x100"
  image.write("output.jpg")

Want to make a thumbnail from a blob…

  image = MiniMagick::Image.from_blob(blob)
  image.resize "100x100"
  image.write("output.jpg")

Need to combine several options?

  image = MiniMagick::Image.from_file("input.jpg")
  image.combine_options do |c|
    c.sample "50%"
    c.rotate "-90>"
  end
  image.write("output.jpg")

Want to manipulate an image at its source (You won’t have to write it out because the transformations are done on that file)

  image = MiniMagick::Image.new("input.jpg")
  image.resize "100x100"

Want to get some meta-information out?

  image = MiniMagick::Image.from_file("input.jpg")
  image[:width]               # will get the width (you can also use :height and :format)
  image["EXIF:BitsPerSample"] # It also can get all the EXIF tags
  image["%m:%f %wx%h"]        # Or you can use one of the many options of the format command

For more on the format command see www.imagemagick.org/script/command-line-options.php#format

Requirements

You must have ImageMagick installed.