Code Monkey home page Code Monkey logo

image_sorcery's Introduction

Image Sorcery allows you to leverage all three of ImageMagick's command line tools, mogrify, convert, and identify, for maximum magickal power and minimum memory consumption! It even lets you use GraphicsMagick, too, if that's your thing.

Gem Version Build Status

Why?

At Fol.io, we needed server-side image processing to work well and bend to our will. I wrote this because the ImageMagick libraries we tried suffered from at least one of two problems:

  • Large memory consumption/leaking
  • Didn't expose the entire ImageMagick API

ImageSorcery doesn't try to be anything more than a wrapper that exposes the full ImageMagick and GraphicsMagick APIs. This makes it small and powerful, eliminating the above problems.

Installation

gem install image_sorcery

Code Examples

image = ImageSorcery.new("image.png")
image.identify # => "image.png PNG 500x500 500x500+0+0 8-bit DirectClass 236KB 0.010u 0:00.010\n"
image.manipulate!(scale: "50%") # => true
image.dimensions # => { x: 250, y: 250 }
image.convert("thumbnail.jpg", quality: 80, crop: "100x100>") # => true
image = ImageSorcery.new("multi-page.pdf")
image.filename_changed? # => false
image.manipulate!(format: "png", layer: 0) # => true
image.filename_changed? # => true
image.file # => "multi-page.png"
image = ImageSorcery.new("multi-page.pdf")
image.manipulate!(format: "png") # => true
image.filename_changed? # => true

# on ImageMagick it returns all layers as a single file
image.file # => "multi-page-*.png"

# on GrapicksMagick it returns only the fist layer
image.file # => "multi-page.png"

Using GraphicsMagick

Assuming you have GraphicsMagick installed on your box:

image = ImageSorcery.gm("image.png")
# use as normal

Todo

  • Some more unit tests
  • A few more convenience methods (like "dimensions").

image_sorcery's People

Contributors

ericr avatar tmaier avatar mroth avatar brandondrew avatar florentsolt avatar guyboertje avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.