操作

A

adjoin
gm("img.png").adjoin()
affine
gm("img.png").affine(matrix)
antialias

所有图片默认是 anti-aliased by GraphicsMagick. To disable it pass false.

gm("img.png").antialias(false)

append - 附加一组图像

参数

  • img

    • 另一张图片地址
  • ltr (可选)

    • Boolean - 指定附加位置
    • true 是 left-to-right 左到右
    • false 是 top-to-bottom (默认上到下)
  gm("img.png").append(img [, img, ltr])

  // appends another.jpg to img.png from left-to-right
  gm("img.png").append("another.jpg").append(true)

  // appends another.jpg to img.png from left-to-right
  gm("img.png").append("another.jpg", true)

  // appends another.jpg to img.png from top-to-bottom
  gm("img.png").append("another.jpg")

  // appends third.gif below another.jpg below img.png
  gm("img.png").append("another.jpg").append("third.gif")

  // appends third.gif below another.jpg below img.png
  gm("img.png").append("another.jpg", "third.gif")

  // appends third.gif to the right of another.jpg to the right to img.png
  gm("img.png").append("another.jpg", "third.gif", true)
authenticate
  gm("img.png").authenticate(password)
autoOrient

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()
average
gm("img.png").average()

B

backdrop
gm("img.png").backdrop()
bitdepth

Specifies the number of bits of color to preserve in the image. See the docs for more detail.

gm("img.png").bitdepth(bits)

blackThreshold

pixels below threshold become black.

gm("img.png").blackThreshold(red [,green] [,blue] [,opacity])

bluePrimary
gm("img.png").bluePrimary(x, x)
blur

Accepts a radius and optional sigma (standard deviation).

gm("img.png").blur(radius [, sigma])

border
gm("img.png").border(width, height)
borderColor
gm("img.png").borderColor(color)
box
gm("img.png").box(color)

C

channel

type Red, Green, Blue, Opacity, Matte, Cyan, Magenta, Yellow, Black, or Gray

gm("img.png").channel(type)

charcoal

Simulates a charcoal drawing. Accepts a factor.

gm("img.png").charcoal(factor)

chop

Removes pixels from the interior of an image.

gm("img.png").chop(width, height, x, y)

clip
gm("img.png").clip()
coalesce
gm("img.png").coalesce()
colorize

Colorize the image with optionally separate red, green, and blue values.

gm("img.png").colorize(red [, green [, blue]])

colorMap

type shared or private

gm("img.png").colorMap(type)

colors

Sets the preferred number of colors for the image (color reduction).

gm("img.png").colors(int)

colorspace

Specifies the type of colorspace. See the GraphicsMagick docs for val details.

gm("img.png").colorspace(val)

compose
gm("img.png").compose(operator)
compress

type None, BZip, Fax, Group4, JPEG, Lossless, LZW, RLE, Zip, or LZMA

gm("img.png").compress(type)

comment

Annotates an image. See the docs for more info.

gm("img.png").comment(text|format)

contrast

Increases or reduces the image contrast. Accepts a multiplier.

gm("img.png").contrast([+-]multiplier)

convolve
gm("img.png").convolve(kernel)
createDirectories
gm("img.png").createDirectories()
crop

Crops the image to the given width and height at the given x and y position.

gm("img.png").crop(width, height, x, y)

cycle

Displace the image colormap by amount. amount is the number of positions each colormap entry is shifted.

gm("img.png").cycle(amount)

D

deconstruct
gm("img.png").deconstruct()
define
gm("img.png").define()
delay

amount is in hundreths of a second.

gm("img.png").delay(amout)

density

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)

despeckle

Reduces the speckles within the image.

gm("img.png").despeckle()

displace

Shift image pixels as defined by a displacement map.

gm("img.png").displace(horizontal, vertical)

display
gm("img.png").display(value)
dispose
gm("img.png").dispose(method)
dissolve
gm("img.png").dissolve(method)
dither

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])

E

edge

Emphasizes edges in an image. Takes an optional radius of the emphasis to apply.

gm("img.png").edge([radius])

emboss

Embosses the image. Takes an optional radius.

gm("img.png").emboss([radius])

encoding

type AdobeCustom, AdobeExpert, AdobeStandard, AppleRoman, BIG5, GB2312, Latin 2, None, SJIScode, Symbol, Unicode, Wansung gm("img.png").encoding(type) ```

endian

type MSB, LSB, or Native

gm("img.png").endian(type)

enhance

Enhances the image.

gm("img.png").enhance()

equalize

Performs histogram equalization to the image.

gm("img.png").equalize()

extent

composite image on background color canvas image.

gm("img.png").extent([width, height, options])

F

file
gm("img.png").file(filename)
filter

Specifies the filter to use when resizing. see link for available types.

gm("img.png").filter(type)

flatten
gm("img.png").flatten()
flip

Creates a mirror image (vertically).

gm("img.png").flip()

flop

Creates a mirror image (horizontally).

gm("img.png").flop()

foreground
gm("img.png").foreground(color)
frame
gm("img.png").frame(width, height, outerBevelWidth, innerBevelWidth)
fuzz
gm("img.png").fuzz(distance [,percent])

G

gamma

Adjusts the level of gamma correction.

gm("img.png").gamma(r, g, b)

gaussian
gm("img.png").gaussian(radius [,sigma])
geometry
gm("img.png").geometry(width, height [,arg])
greenPrimary
gm("img.png").greenPrimary(x, y)
gravity

The direction the primitive gravitates to when annotating the image. Defaults to NorthWest. direction NorthWest|North|NorthEast|West|Center|East|SouthWest|South|SouthEast

gm("img.png").gravity(direction)

H

highlightColor
gm("img.png").highlightColor(color)
highlightStyle
gm("img.png").highlightStyle(color)

I

iconGeometry
gm("img.png").iconGeometry(geometry)
implode

Implodes the image pixels around the center. Takes an optional factor.

gm("img.png").implode([factor])

intent

type Absolute, Perceptual, Relative, or Saturation

gm("img.png").intent(type)

interlace

Specifies the type of interlacing scheme. Defaults to None.

type None|Line|Plane|Partition

gm("img.png").interlace(type)

L

label

Assigns a label to an image.

gm("img.png").label(name)

lat
gm("img.png").lat(width, height, offset [,percent])
level
gm("img.png").level(blackPoint, gamma, whitePoint [,percent])
limit

Sets resource limits.

type disk|file|map|memory|pixels|threads val follows the same rules as specified in the GraphicsMagick docs

gm("img.png").limit(type, val)

list

type Color, Delegate, Format, Magic, Module, Resource, or Type

  gm("img.png").list(type)

log

Specify format for debug log. 详情请参阅文档。

gm("img.png").log(format)

loop

详情请参阅文档。

gm("img.png").loop(iterations)

lower

Creates a pseudo 3D lowering effect of the images edges.

gm("img.png").lower(width, height)

M

magnify

Magnifies the image factor times.

gm("img.png").magnify(factor)

map

详情请参阅文档。

gm("img.png").map(filename)

mask

详情请参阅文档。

gm("img.png").mask(filename)

matte

详情请参阅文档。

gm("img.png").matte()

matteColor

详情请参阅文档。

gm("img.png").matteColor(color)

maximumError

详情请参阅文档。

gm("img.png").maximumError(limit)

median

Applies a median filter to the image. The optional param radius adjusts the weight of the effect.

gm("img.png").median([radius])

minify

Minifies the image factor times.

gm("img.png").minify(factor)

mode

详情请参阅文档。

gm("img.png").mode(value)

modulate

Varies the brightness, saturation, and hue of the image.

gm("img.png").modulate(b [, s [, h]])

monitor

详情请参阅文档。

gm("img.png").monitor()

monochrome

Transforms the image to black and white.

gm("img.png").monochrome()

morph

Morphs two images together.

otherImg

the path to another img

outName

the path where the image will be saved

callback

A function to be executed when morphing is complete. callback will be passed the standard args that .write() receives.

gm("img.png").morph(otherImg, outName, callback)

mosaic

详情请参阅文档。

gm("img.png").mosaic()

motionBlur

详情请参阅文档。

gm("img.png").motionBlur(radius [, sigma, angle])

N

name

详情请参阅文档。

gm("img.png").name()

negative

Replaces every pixel with its complementary color.

gm("img.png").negative()

noise

Add or reduce noise in the image. adius|type To add noise pass one of the following: uniform gaussian multiplicative impulse laplacian poisson Otherwise the argument will be interpreted as a radius which adjusts the weight of the effect.

gm("img.png").noise(radius|type)

noop

详情请参阅文档。

gm("img.png").noop()

normalize

详情请参阅文档。

gm("img.png").normalize()

O

opaque

详情请参阅文档。

gm("img.png").opaque(color)

operator

详情请参阅文档。

gm("img.png").operator(channel, operator, rvalue [,percent])

orderedDither

详情请参阅文档。

gm("img.png").orderedDither(channelType, NxN)

outputDirectory

详情请参阅文档。

gm("img.png").outputDirectory(channelType, NxN)

P

page

详情请参阅文档。

gm("img.png").page(width, height [,arg])

pause

详情请参阅文档。

gm("img.png").pause(seconds)

pen

详情请参阅文档。

gm("img.png").pen(color)

ping

详情请参阅文档。

gm("img.png").ping()

pointSize

详情请参阅文档。

gm("img.png").pointSize(value)

noProfile

Removes EXIF, ICM, etc profile data.

gm("img.png").noProfile()

preview

type See the docs for valid types.

gm("img.png").preview(type)

paint

Simulates an oil painting.

gm("img.png").paint(radius)

process

详情请参阅文档。

gm("img.png").process(command)

profile

详情请参阅文档。

gm("img.png").profile(filename)

progress

详情请参阅文档。

gm("img.png").progress()

randomThreshold

详情请参阅文档。

gm("img.png").randomThreshold(channelType, LOWxHIGH)

Q

quality

Adjusts the jpeg|miff|png|tiff compression level. val ranges from 0 to 100 (best).

gm("img.png").quality(val)

R

raise

Creates a pseudo 3D raising effect of the images edges.

gm("img.png").raise(width, height)

recolor

详情请参阅文档。

gm("img.png").recolor(matrix)

redPrimary

详情请参阅文档。

gm("img.png").redPrimary(x, y)

region

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.

remote

详情请参阅文档。

gm("img.png").remote()

render

详情请参阅文档。

gm("img.png").render()

repage

详情请参阅文档。

gm("img.png").repage(width, height, xoff, yoff, arg)

S

sample

详情请参阅文档。

gm("img.png").sample(geometry)

samplingFactor

详情请参阅文档。

gm("img.png").samplingFactor(horizontalFactor, verticalFactor)

rawSize

详情请参阅文档。

gm("img.png").rawSize(width, height, offset)

resample

Resamples the image to specified horizontal and vertical resolution.

    gm("img.png").resample(horizontal, vertical)
resize

调整图像的大小.

选项

%, @, !, < or > see the GraphicsMagick docs for details

    gm("img.png").resize(width [, height [, options]])
To resize an image to a width of 40px while maintaining aspect ratio: gm("img.png").resize(40)

To resize an image to a height of 50px while maintaining aspect ratio: gm("img.png").resize(null, 50)

To resize an image to a fit a 40x50 rectangle while maintaining aspect ratio: gm("img.png").resize(40, 50)

To override the image's proportions and force a resize to 40x50: gm("img.png").resize(40, 50, "!")

roll

Rolls an image vertically or horizontally.

gm("img.png").roll(horizontalInt, verticalInt)

rotate

Rotates the image by degrees and fills the background with color.

gm("img.png").rotate(color, degrees)

S

scene

详情请参阅文档。

gm("img.png").scene(value)

scenes

详情请参阅文档。

gm("img.png").scenes(start, end)

scale

Scales the image.

gm("img.png").scale(width, height)

screen

详情请参阅文档。

gm("img.png").screen()
segment

详情请参阅文档。

gm("img.png").segment(clusterThreshold, smoothingThreshold)
selectFrame

Helpful if we process a large .gif so we don't load in memory each frame.

gm("img.png").selectFrame(0)
sepia

A convenience method to apply a sepia effect to the image.

gm("img.png").sepia()
set

详情请参阅文档。

gm("img.png").set(attribute, value)
setFormat

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)
shade

详情请参阅文档。

gm("img.png").shade(azimuth, elevation)
shadow

详情请参阅文档。

gm("img.png").shadow(radius, sigma)
sharedMemory

详情请参阅文档。

gm("img.png").sharedMemory()
shave

详情请参阅文档。

gm("img.png").shave(width, height, percent)
sharpen

Sharpens the image.

gm("img.png").sharpen(radius [, sigma])
shear

详情请参阅文档。

gm("img.png").shear(xDegrees, yDegrees)
silent

详情请参阅文档。

gm("img.png").silent()
snaps

详情请参阅文档。

gm("img.png").snaps(value)
solarize

Negates all pixels above threshold percent.

gm("img.png").solarize(threshold)
spread

Desplaces pixels by a random amount.

gm("img.png").spread(amount)
stegano

详情请参阅文档。

gm("img.png").stegano(offset)
stereo

详情请参阅文档。

gm("img.png").stereo()
strip

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()
swirl

Swirls pixels arount the center of the image. degrees specifies the tightness of the swirl.

gm("img.png").swirl(degrees)

T

textFont

详情请参阅文档。

gm("img.png").textFont(font)
texture

详情请参阅文档。

gm("img.png").texture(font)
threshold

详情请参阅文档。

gm("img.png").threshold(value [, percent])
thumb

Creates a thumbnail based on minimum sizes.

width the minimum width of the thumbnail height the minimum height of the thumbnail outName the path where the image will be saved quality Adjusts the image compression level. Ranges from 0 to 100 (best). callback called after the thumbnail is written. receives the same args that .write(err, stdout, stderr, command) receives. gm("img.png").thumb(width, height, outName, quality, callback)

tile

详情请参阅文档。

gm("img.png").tile(filename)
title

详情请参阅文档。

gm("img.png").title(string)
transform

详情请参阅文档。

gm("img.png").transform(color)
transparent

详情请参阅文档。

gm("img.png").transparent(color)
treeDepth

详情请参阅文档。

gm("img.png").treeDepth(color)
trim

Trim an image by removing any edges that are exactly the same color as the corner pixels.

gm("img.png").trim()
type

Specifies the image type.

type Can be one of the following: Bilevel Grayscale Palette PaletteMatte TrueColor TrueColorMatte ColorSeparation ColorSeparationMatte Optimize gm("img.png").type(type)

U

update

详情请参阅文档。

gm("img.png").update(seconds)
units

详情请参阅文档。

gm("img.png").units(type)
unsharp

详情请参阅文档。

gm("img.png").unsharp(radius [, sigma, amount, threshold])
usePixmap

详情请参阅文档。

gm("img.png").usePixmap()

V

view

详情请参阅文档。

gm("img.png").view()
virtualPixel

详情请参阅文档。

gm("img.png").virtualPixel(method)
visual

详情请参阅文档。

gm("img.png").visual(type)

W

watermark

详情请参阅文档。

gm("img.png").watermark(brightness, saturation)

wave

详情请参阅文档。

gm("img.png").wave(amplitude, wavelength)

whitePoint

详情请参阅文档。

gm("img.png").whitePoint(x, y)

whiteThreshold

详情请参阅文档。

gm("img.png").whiteThreshold(red, green, blue, opacity)

window

详情请参阅文档。

gm("img.png").window(id)

windowGroup

详情请参阅文档。

gm("img.png").windowGroup()