gm

gm (GitHub: aheckmann/gm, License: MIT) is ImageMagick for node, what else is there to say?

1
npm install gm

ImageMagick is a software suite to create, edit, compose, or convert bitmap images. It can read and write images in a variety of formats (over 100) including DPX, EXR, GIF, JPEG, JPEG-2000, PDF, PNG, Postscript, SVG, and TIFF. Use ImageMagick to resize, flip, mirror, rotate, distort, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and Bézier curves.

The demo page has an interactive playground that shows a tiny fraction of what gm can do.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
var gm = require('./gm');
// resize and remove EXIF profile data
gm('/path/to/my/img.jpg')
  .resize(240, 240)
  .noProfile()
  .write('/path/to/resize.png', function (err) {
    if (!err) console.log('done');
  });
// annotate an image
gm('/path/to/my/img.jpg')
  .stroke("#ffffff")
  .drawCircle(10, 10, 20, 10)
  .font("Helvetica.ttf", 12)
  .drawText(30, 20, "GMagick!")
  .write("/path/to/drawing.png", function (err) {
    if (!err) console.log('done');
  });

There are plenty of examples and information on the
github page. Check it out!

Post navigation

Leave a comment

Leave a Reply

Your email address will not be published.