Socket
Book a DemoInstallSign in
Socket

graphicsmagick

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphicsmagick

1.0.6
bundlerRubygems
Version published
Maintainers
1
Created
Source

Graphicsmagick

A very light Ruby wrapper for the Graphicsmagick CLI that supports mogrify, composite, and convert, plus a few convenience methods.

Why?

Graphicsmagick was 10x faster for our image processing needs than ImageMagick. I wanted to use Graphicsmagick, but wanted a Ruby wrapper to help deal with exceptions and long running tasks. I needed to use multiple utilities within Graphicsmagick and the current crop of *_magick gems either did not support all of them, or had costly overhead (or both).

Installation

Install Graphicsmagick

http://www.graphicsmagick.org/README.html

On OS X, it's recommended to use brew

brew update
brew install graphicsmagick

Install gem

Add this line to your application's Gemfile:

gem 'graphicsmagick'

And then execute:

$ bundle

Or install it yourself as:

$ gem install graphicsmagick

Usage

Mogrify commands and overwriting file

img = GraphicsMagick::Image.new('my_file.jpg')
img.crop('360x504+432+72').resize('125x177!')
img.write!

Equivalent to

gm mogrify -crop '360x504+432+72' -resize '125x177!' my_file.jpg

Mogrify commands and write to new file

img = GraphicsMagick::Image.new('my_file.jpg')
img.crop('360x504+432+72').resize('125x177!')
img.write('my_new_file.jpg')

Equivalent to

cp my_file.jpg my_new_file.jpg & gm mogrify -crop '360x504+432+72' -resize '125x177!' my_new_file.jpg

Convert a PDF file to a PNG while passing options at both steps

img = GraphicsMagick::Image.new("my_file.pdf")
img.strip.density(144).colorspace('RGB').auto-orient
img.convert.resize('50%')
img.write('my_new_file.png')

Equivalent to

gm convert -density 144 -strip -colorspace RGB -auto-orient "my_file.pdf" -resize '50%' my_new_file.png

Composite an image over another image

background = GraphicsMagick::Image.new("background.png")
img = GraphicsMagick::Image.new("overlay.png")
img.composite(background).geometry('+100+150')
img.write('composite.png')

Equivalent to

gm composite -geometry +100+150 background.png overlay.png composite.png

You can pass a file too

file = File.new('my_file.png')
img = GraphicsMagick::Image.new(file)

temp_img = GraphicsMagick::Image.new(Tempfile.new('foo'))
temp_img.path  #=> "path/to/temp/file"

Contributing

  • Fork it
  • Create your feature branch (git checkout -b my-new-feature)
  • Commit your changes (git commit -am 'Add some feature')
  • Push to the branch (git push origin my-new-feature)
  • Create new Pull Request

FAQs

Package last updated on 12 May 2018

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.