Skip to content


Subversion checkout URL

You can clone with
Download ZIP
mini replacement for RMagick
Ruby Perl PHP
Branch: master
Pull request Compare This branch is 372 commits behind minimagick:master.
Failed to load latest commit information.
test Properly escape arguments to prevent shell injection
.gitignore Refactored the entire gem and fixed a few bugs, requires fix for sube…
.travis.yml run on more rubies
CHANGELOG release version 3.4
Gemfile merge
Gemfile.lock merge
MIT-LICENSE gobbled up a bunch of remvees patches
README.rdoc Mention gem's name in the README.
Rakefile update Rakefile to use bundler packaging
VERSION release version 3.4
mini_magick.gemspec merge



A ruby wrapper for ImageMagick or GraphicsMagick command line.

Tested on both Ruby 1.9.2 and Ruby 1.8.7.



gem "mini_magick"

to your Gemfile.


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|

…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.


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


Want to make a thumbnail from a file…

image ="input.jpg")
image.resize "100x100"
image.write  "output.jpg"

Want to make a thumbnail from a blob…

image =
image.resize "100x100"
image.write  "output.jpg"

Got an incoming IOStream?

image =

Want to make a thumbnail of a remote image?

image ="")
image.resize "5x5"
image.format "gif"
image.write "localcopy.gif"

Need to combine several options?

image ="input.jpg")
image.combine_options do |c|
  c.sample "50%"
  c.rotate "-90>"
image.write "output.jpg"

Want to composite two images? Super easy! (Aka, put a watermark on!)

image ="original.png")
result = image.composite("watermark.png", "jpg")) do |c|
  c.gravity "center"
result.write "my_output_file.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 ="input.jpg")
image.resize "100x100"

Want to get some meta-information out?

image ="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

Windows Users

When passing in a blob or IOStream, Windows users need to make sure they read the file in as binary.

#This way works on Windows
buffer =,"rb") { |f| })

#You may run into problems doing it this way
buffer =

Using GraphicsMagick

Simply set

MiniMagick.processor = :gm

And you are sorted.


You must have ImageMagick or GraphicsMagick installed.

Something went wrong with that request. Please try again.