Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mini_magick2

Package Overview
Dependencies
Maintainers
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mini_magick2

  • 1.0.0
  • Rubygems
  • Socket score

Version published
Maintainers
4
Created
Source

= MiniMagick

A ruby wrapper for ImageMagick or GraphicsMagick command line.

Tested on both Ruby 1.9.2 and Ruby 1.8.7.

== 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 http://www.imagemagick.org/script/mogrify.php)

== Examples

Want to make a thumbnail from a file...

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

Want to make a thumbnail from a blob...

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

Got an incoming IOStream?

image = MiniMagick::Image.read(stream)

Want to make a thumbnail of a remote image?

image = MiniMagick::Image.open("http://www.google.com/images/logos/logo.png") image.resize "5x5" image.format "gif" image.write "localcopy.gif"

Need to combine several options?

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

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

image = Image.from_file("original.png") result = image.composite(Image.open("watermark.png", "jpg") do |c| c.gravity "center" end 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 = MiniMagick::Image.new("input.jpg") image.resize "100x100"

Want to get some meta-information out?

image = MiniMagick::Image.open("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 http://www.imagemagick.org/script/command-line-options.php#format

== Requirements

You must have ImageMagick or GraphicsMagick installed.

FAQs

Package last updated on 15 Aug 2011

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc