By default all imgs are anti-aliased by GrahpicsMagick. To disable it pass false.
gm("img.png").antialias(false)
Auto-orients the image according to its EXIF data.
GraphicsMagick doesn't actually have the -auto-orient option but we emulate this by first reading the EXIF data and rotate/flip from there.
gm("img.jpg").autoOrient()
Specifies the number of bits of color to preserve in the image. See the docs for more detail.
gm("img.png").bitdepth(bits)
Accepts a radius and optional sigma (standard deviation).
gm("img.png").blur(radius [, sigma])
Simulates a charcoal drawing. Accepts a factor.
gm("img.png").charcoal(factor)
Removes pixels from the interior of an image.
gm("img.png").chop(width, height, x, y)
Sets the preferred number of colors for the image (color reduction).
gm("img.png").colors(int)
Colorize the image with optionally separate red, green, and blue values.
gm("img.png").colorize(red [, green [, blue]])
Specifies the type of colorspace. See the GraphicsMagick
docs for val details.
gm("img.png").colorspace(val)
Annotates an image. See the docs for more info.
gm("img.png").comment(text|format)
Increases or reduces the image contrast. Accepts a multiplier.
gm("img.png").contrast([+-]multiplier)
Crops the image to the given width and height at the given x and y position.
gm("img.png").crop(width, height, x, y)
Displace the image colormap by amount. amount is the number of positions each colormap entry is shifted.
gm("img.png").cycle(amount)
This option specifies the image resolution to store while encoding a raster image or the canvas resolution while rendering (reading) vector formats into an image.
gm("img.png").density(width, height)
Reduces the speckles within the image.
gm("img.png").despeckle()
Applies Floyd/Steinberg error diffusion to the image. Pass false to disable dithering.
Note: either .colors() or .monochrome() must be used for this to take effect.
gm("img.png").dither([bool])
Emphasizes edges in an image. Takes an optional radius of the emphasis to apply.
gm("img.png").edge([radius])
Embosses the image. Takes an optional radius.
gm("img.png").emboss([radius])
Enhances the image.
gm("img.png").enhance()
Performs histogram equalization to the image.
gm("img.png").equalize()
composite image on background color canvas image.
gm("img.png").extent([width, height, options])
Specifies the filter to use when resizing. see link for available types.
gm("img.png").filter(type)
Creates a mirror image (vertically).
gm("img.png").flip()
Creates a mirror image (horizontally).
gm("img.png").flop()
Adjusts the level of gamma correction.
gm("img.png").gamma(r, g, b)
The direction the primitive gravitates to when annotating the image. Defaults to NorthWest.
directiongm("img.png").gravity(direction)
Implodes the image pixels around the center. Takes an optional factor.
gm("img.png").implode([factor])
Specifies the type of interlacing scheme. Defaults to None.
typegm("img.png").interlace(type)
Assigns a label to an image.
gm("img.png").label(name)
Sets resource limits.
typevalgm("img.png").limit(type, val)
Creates a pseudo 3D lowering effect of the images edges.
gm("img.png").lower(width, height)
Magnifies the image factor times.
gm("img.png").magnify(factor)
Applies a median filter to the image. The optional param radius adjusts the weight of the effect.
gm("img.png").median([radius])
Minifies the image factor times.
gm("img.png").minify(factor)
Varies the brightness, saturation, and hue of the image.
gm("img.png").modulate(b [, s [, h]])
Transforms the image to black and white.
gm("img.png").monochrome()
Morphs two images together.
otherImgoutNamecallbackcallback will be passed the standard args that .write() receives.gm("img.png").morph(otherImg, outName, callback)
Replaces every pixel with its complementary color.
gm("img.png").negative()
Add or reduce noise in the image.
radius|typeradius which adjusts the weight of the effect.gm("img.png").noise(radius|type)
Removes EXIF, ICM, etc profile data.
gm("img.png").noProfile()
Simulates an oil painting.
gm("img.png").paint(radius)
Adjusts the jpeg|miff|png|tiff compression level. val ranges from 0 to 100 (best).
gm("img.png").quality(val)
Creates a pseudo 3D raising effect of the images edges.
gm("img.png").raise(width, height)
Specifies that all following methods only apply to the area specified by width, height, x, y.
gm("img.png").region(width, height, x, y).sepia()
In this case, the sepia effect would only be applied within the area specified by width, height, x, y.
Resamples the image to specified horizontal and vertical resolution.
gm("img.png").resample(horizontal, vertical)
Resize the image.
gm("img.png").resize(width, height)
Rolls an image vertically or horizontally.
gm("img.png").roll(horizontalInt, verticalInt)
Rotates the image by degrees and fills the background with color.
gm("img.png").rotate(color, degrees)
Scales the image.
gm("img.png").scale(width, height)
A convenience method to apply a sepia effect to the image.
gm("img.png").sepia()
Overriddes the output image format.
Helpful if we are outputting an image with no extention but need to change formats.
gm("img.png").setFormat(format)
Negates all pixels above threshold percent.
gm("img.png").solarize(threshold)
Desplaces pixels by a random amount.
gm("img.png").spread(amount)
Strips the image of any profiles or comments.
Similar to noProfile() but removes both profile and comment data. only works with imageMagick.
gm("img.png").strip()
Swirls pixels arount the center of the image. degrees specifies the tightness of the swirl.
gm("img.png").swirl(degrees)
Creates a thumbnail based on minimum sizes.
widthheightoutNamequalitycallback.write(err, stdout, stderr, command) receives.gm("img.png").thumb(width, height, outName, quality, callback)
Trim an image by removing any edges that are exactly the same color as the corner pixels.
gm("img.png").trim()
Specifies the image type.
typegm("img.png").type(type)
All getters have the same signature:
gm("image.png").size(function(err, value){
// note : value may be undefined
})
size - returns the size (WxH) of the imageformat - returns the image format (gif, jpeg, png, etc)depth - returns the image color depthcolor - returns the number of colorsres - returns the image resolutionfilesize - returns image filesizeidentify - returns all image data availableorientation - returns the EXIF orientation of the imageTake a look at drawing.js for examples.
Annotate an image with one or more graphic primitives (shapes, text, transformations, pixel operations). Used internally for all drawing methods.
gm("img.png").draw(args)
Inscribe an elliptical arc within a rectangle. Requires a start and end point as well as the degrees of rotation.
gm("img.png").drawArc(x0, y0, x1, y1, r0, r1)
Draw a Bezier curve.
gm("img.png").drawBezier([x0, y0], ... [xn, yn])
Draws a Circle.
gm("img.png").drawCircle(x0, y0, x1, y1)
Draws an Ellipse.
gm("img.png").drawEllipse(x0, y0, r0, ry, r0, r1)
Draws a Line.
gm("img.png").drawLine(x0, y0, x1, y1)
Draws a Point.
gm("img.png").drawPoint(x, y)
Draws a Polygon.
gm("img.png").drawPolygon([x0, y0] ... [xn, yn])
Draws a Polyline.
gm("img.png").drawPolyline([x0, y0] ... [xn, yn])
Draws a Rectangle. wc and hc are optional and add roundness to the corners.
gm("img.png").drawRectangle(x0, y0, x1, y1 [, wc, hc])
Draws text on an image at x/y coordinates.
gm("img.png").drawText(x, y, text [, gravity])
Specifies the color to use when filling a drawn shape.
gm("img.png").fill(color)
Specifies the font to use when you drawText.
gm("img.png").font(name)
Specifies the font size to use when you drawText.
gm("img.png").fontSize(size)
Specifies the color to use when stroking a drawn shape.
gm("img.png").stroke(color [, width])
Specifies the stroke width to use when stroking a drawn shape.
gm("img.png").strokeWidth(width)
Sets drawing properties. property can be either "color" or "matte".
gm("img.png").setDraw(property, x, y, method)
We have compatibility with ImageMagick too. Just subclass the gm constructor passing the imageMagick option.
var imageMagick = gm.subClass({ imageMagick: true });
Then use imageMagick the same way you'd normally use gm.
imageMagick("img.png").autoOrient().write('/path', callback);