Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/EricR/image_sorcery
A ruby Image/Graphics Magick library. Note: This project is no longer maintained.
https://github.com/EricR/image_sorcery
Last synced: 3 months ago
JSON representation
A ruby Image/Graphics Magick library. Note: This project is no longer maintained.
- Host: GitHub
- URL: https://github.com/EricR/image_sorcery
- Owner: EricR
- Created: 2012-06-09T08:36:32.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2013-01-21T21:17:51.000Z (almost 12 years ago)
- Last Synced: 2024-05-13T01:04:59.162Z (6 months ago)
- Language: Ruby
- Homepage:
- Size: 2.17 MB
- Stars: 283
- Watchers: 10
- Forks: 23
- Open Issues: 3
-
Metadata Files:
- Readme: README.markdown
Awesome Lists containing this project
README
Image Sorcery allows you to leverage all three of ImageMagick's command line tools, [mogrify](http://www.imagemagick.org/script/mogrify.php), [convert](http://www.imagemagick.org/script/convert.php), and [identify](http://www.imagemagick.org/script/identify.php), for maximum magickal power and minimum memory consumption! It even lets you use GraphicsMagick, too, if that's your thing.
[![Gem Version](https://badge.fury.io/rb/image_sorcery.png)](http://badge.fury.io/rb/image_sorcery)
[![Build Status](https://travis-ci.org/EricR/image_sorcery.png?branch=master)](https://travis-ci.org/EricR/image_sorcery/)## Why?
At [Fol.io](http://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 APIImageSorcery 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
```ruby
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
``````ruby
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"
``````ruby
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:```ruby
image = ImageSorcery.gm("image.png")
# use as normal
```## Todo
* Some more unit tests
* A few more convenience methods (like "dimensions").