gim

0.0.1 • Public • Published

gim Build Status

ImageMagick and GraphicsMagick child process wrapper.

API

Switching between GraphicsMagick or ImageMagick

By default, each instance checks for gim.prototype.GraphicsMagick. You can either set this value on the prototype or a subclass. You can also set the library as an option on each instance.

var gim = require('gim')
gim.prototype.GraphicsMagick = true

or

var gim = require('gim').extend()
gim.prototype.GraphicsMagick = true

or

var gim = require('gim')
 
gim('img.png', {
  GraphicsMagick: true
})

or

var gim = require('gim')
 
gim('img.png', {
  ImageMagick: false
})

Inputs

Inputs can either be:

  • filename
  • Buffer
  • Readable Stream

The first way to use it is as an argument:

gim(filename)
gim(buffer)
gim(stream)

Another way is to use it as stream:

gim().spawn().end(buffer)
stream.pipe(gim().spawn())

Note: You can not use a gim() instance as a stream until gim().spawn() (or a method that executes it) is called as the underlying child process has not yet been spawned.

Outputs

If you want a string output, such as when using gim().identify(), you can use gim().toString(callback).

gim('img.png').identify(function (err, value) {
 
})

is equivalent to:

gim().exec('identify', ['-verbose', 'img.png'], function (err, value) {
 
})

You can also pipe gim as a stream by using gim().pipe(). Note that you must gim().spawn() before you using gim as a stream:

gim('img.png').convert('-quality', '80').pipe(fs.createWriteStream('img.jpg'))

License

The MIT License (MIT)

Copyright (c) 2013 Jonathan Ong me@jongleberry.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Readme

Keywords

none

Package Sidebar

Install

npm i gim

Weekly Downloads

3

Version

0.0.1

License

MIT

Last publish

Collaborators

  • jongleberry