|
|
|
@ -7,105 +7,107 @@ module.exports = function (proto) { |
|
|
|
|
|
|
|
|
|
// http://www.graphicsmagick.org/GraphicsMagick.html#details-resize
|
|
|
|
|
proto.resize = function resize (w, h) { |
|
|
|
|
return this.arg(["-size", w +"x"+ h], ["-resize ", w +"x"+ h]); |
|
|
|
|
return this.in("-size", w +"x"+ h).out("-resize", w +"x"+ h); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// http://www.graphicsmagick.org/GraphicsMagick.html#details-scale
|
|
|
|
|
proto.scale = function scale (w, h) { |
|
|
|
|
return this.arg(null, ["-scale", w +"x"+ h]); |
|
|
|
|
return this.out("-scale", w +"x"+ h); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// http://www.graphicsmagick.org/GraphicsMagick.html#details-profile
|
|
|
|
|
proto.noProfile = function noProfile () { |
|
|
|
|
return this.arg(null, ['+profile "*"']); |
|
|
|
|
// profile has a lame particularity so we don't escape
|
|
|
|
|
this._out.push('+profile "*"'); |
|
|
|
|
return this; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// http://www.graphicsmagick.org/GraphicsMagick.html#details-resample
|
|
|
|
|
proto.resample = function resample (w, h) { |
|
|
|
|
return this.arg(null, ["-resample", w+"x"+h]); |
|
|
|
|
return this.out("-resample", w+"x"+h); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// http://www.graphicsmagick.org/GraphicsMagick.html#details-rotate
|
|
|
|
|
proto.rotate = function rotate (color, deg) { |
|
|
|
|
return this.arg(null, ["-background", color]).arg(null, ["-rotate", deg]); |
|
|
|
|
return this.out("-background", color, "-rotate", deg); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// http://www.graphicsmagick.org/GraphicsMagick.html#details-flip
|
|
|
|
|
proto.flip = function flip () { |
|
|
|
|
return this.arg(null, ["-flip"]); |
|
|
|
|
return this.out("-flip"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// http://www.graphicsmagick.org/GraphicsMagick.html#details-flop
|
|
|
|
|
proto.flop = function flop () { |
|
|
|
|
return this.arg(null, ["-flop"]); |
|
|
|
|
return this.out("-flop"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// http://www.graphicsmagick.org/GraphicsMagick.html#details-crop
|
|
|
|
|
proto.crop = function crop (w, h, x, y) { |
|
|
|
|
return this.arg(null, ["-crop", w+"x"+h + "+"+(x||0)+"+"+(y||0)]); |
|
|
|
|
return this.out("-crop", w+"x"+h + "+"+(x||0)+"+"+(y||0)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// http://www.graphicsmagick.org/GraphicsMagick.html#details-chop
|
|
|
|
|
proto.chop = function chop (w, h, x, y) { |
|
|
|
|
return this.arg(["-chop", w+"x"+h + "+"+(x||0)+"+"+(y||0)]); |
|
|
|
|
return this.in("-chop", w+"x"+h + "+"+(x||0)+"+"+(y||0)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// http://www.graphicsmagick.org/GraphicsMagick.html
|
|
|
|
|
proto.magnify = function magnify (factor) { |
|
|
|
|
return this.arg(["-magnify", factor || 1]); |
|
|
|
|
return this.in("-magnify", factor || 1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// http://www.graphicsmagick.org/GraphicsMagick.html
|
|
|
|
|
proto.minify = function minify (factor) { |
|
|
|
|
return this.arg(["-minify", factor || 1]); |
|
|
|
|
return this.in("-minify", factor || 1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// http://www.graphicsmagick.org/GraphicsMagick.html#details-quality
|
|
|
|
|
proto.quality = function quality (val) { |
|
|
|
|
return this.arg(["-quality", val || 75]); |
|
|
|
|
return this.in("-quality", val || 75); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// http://www.graphicsmagick.org/GraphicsMagick.html#details-blur
|
|
|
|
|
proto.blur = function blur (radius, sigma) { |
|
|
|
|
return this.arg(null, ["-blur", radius + (sigma ? "x"+sigma : "") ]); |
|
|
|
|
return this.out("-blur", radius + (sigma ? "x"+sigma : "")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// http://www.graphicsmagick.org/convert.html
|
|
|
|
|
proto.charcoal = function charcoal (factor) { |
|
|
|
|
return this.arg(null, ["-charcoal", factor || 2]); |
|
|
|
|
return this.out("-charcoal", factor || 2); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// http://www.graphicsmagick.org/GraphicsMagick.html#details-colorize
|
|
|
|
|
proto.colorize = function colorize (r, g, b) { |
|
|
|
|
return this.arg(null, ["-colorize", [r,g,b].join(",")]); |
|
|
|
|
return this.out("-colorize", [r,g,b].join(",")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// http://www.graphicsmagick.org/GraphicsMagick.html#details-modulate
|
|
|
|
|
proto.modulate = function modulate (b, s, h) { |
|
|
|
|
return this.arg(null, ["-modulate", [b,s,h].join(",")]); |
|
|
|
|
return this.out("-modulate", [b,s,h].join(",")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// http://www.graphicsmagick.org/GraphicsMagick.html#details-antialias
|
|
|
|
|
// note: antialiasing is enabled by default
|
|
|
|
|
proto.antialias = function antialias (disable) { |
|
|
|
|
return false === disable |
|
|
|
|
? this.arg(null, ["+antialias"]) |
|
|
|
|
? this.out("+antialias") |
|
|
|
|
: this; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// http://www.graphicsmagick.org/GraphicsMagick.html#details-depth
|
|
|
|
|
proto.bitdepth = function bitdepth (val) { |
|
|
|
|
return this.arg(null, ["-depth", val]); |
|
|
|
|
return this.out("-depth", val); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// http://www.graphicsmagick.org/GraphicsMagick.html#details-colors
|
|
|
|
|
proto.colors = function colors (val) { |
|
|
|
|
return this.arg(null, ["-colors", val || 128]); |
|
|
|
|
return this.out("-colors", val || 128); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// http://www.graphicsmagick.org/GraphicsMagick.html#details-colorspace
|
|
|
|
|
proto.colorspace = function colorspace (val) { |
|
|
|
|
return this.arg(null, ["-colorspace", val]); |
|
|
|
|
return this.out("-colorspace", val); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// http://www.graphicsmagick.org/GraphicsMagick.html#details-comment
|
|
|
|
@ -113,28 +115,27 @@ module.exports = function (proto) { |
|
|
|
|
|
|
|
|
|
// http://www.graphicsmagick.org/GraphicsMagick.html#details-contrast
|
|
|
|
|
proto.contrast = function contrast (mult) { |
|
|
|
|
var args = [] |
|
|
|
|
, arg = (parseInt(mult, 10) || 0) > 0 |
|
|
|
|
? "+contrast" |
|
|
|
|
: "-contrast"; |
|
|
|
|
var arg = (parseInt(mult, 10) || 0) > 0 |
|
|
|
|
? "+contrast" |
|
|
|
|
: "-contrast"; |
|
|
|
|
|
|
|
|
|
mult = Math.abs(mult) || 1; |
|
|
|
|
|
|
|
|
|
while (mult--) { |
|
|
|
|
args.push(arg); |
|
|
|
|
this.out(arg); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return this.arg(null, args); |
|
|
|
|
return this; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// http://www.graphicsmagick.org/GraphicsMagick.html#details-cycle
|
|
|
|
|
proto.cycle = function cycle (amount) { |
|
|
|
|
return this.arg(null, ["-cycle", amount || 2]); |
|
|
|
|
return this.out("-cycle", amount || 2); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// http://www.graphicsmagick.org/GraphicsMagick.html
|
|
|
|
|
proto.despeckle = function despeckle () { |
|
|
|
|
return this.arg(null, ["-despeckle"]); |
|
|
|
|
return this.out("-despeckle"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// http://www.graphicsmagick.org/GraphicsMagick.html#details-dither
|
|
|
|
@ -145,42 +146,42 @@ module.exports = function (proto) { |
|
|
|
|
? "+" |
|
|
|
|
: "-"; |
|
|
|
|
|
|
|
|
|
return this.arg(null, [sign + "dither"]); |
|
|
|
|
return this.out(sign + "dither"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// http://www.graphicsmagick.org/GraphicsMagick.html
|
|
|
|
|
proto.monochrome = function monochrome () { |
|
|
|
|
return this.arg(null, ["-monochrome"]); |
|
|
|
|
return this.out("-monochrome"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// http://www.graphicsmagick.org/GraphicsMagick.html
|
|
|
|
|
proto.edge = function edge (radius) { |
|
|
|
|
return this.arg(null, ["-edge", radius || 1]); |
|
|
|
|
return this.out("-edge", radius || 1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// http://www.graphicsmagick.org/GraphicsMagick.html
|
|
|
|
|
proto.emboss = function emboss (radius) { |
|
|
|
|
return this.arg(null, ["-emboss", radius || 1]); |
|
|
|
|
return this.out("-emboss", radius || 1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// http://www.graphicsmagick.org/GraphicsMagick.html
|
|
|
|
|
proto.enhance = function enhance () { |
|
|
|
|
return this.arg(null, ["-enhance"]); |
|
|
|
|
return this.out("-enhance"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// http://www.graphicsmagick.org/GraphicsMagick.html
|
|
|
|
|
proto.equalize = function equalize () { |
|
|
|
|
return this.arg(null, ["-equalize"]); |
|
|
|
|
return this.out("-equalize"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// http://www.graphicsmagick.org/GraphicsMagick.html#details-gamma
|
|
|
|
|
proto.gamma = function gamma (r, g, b) { |
|
|
|
|
return this.arg(null, ["-gamma", [r,g,b].join()]); |
|
|
|
|
return this.out("-gamma", [r,g,b].join()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// http://www.graphicsmagick.org/GraphicsMagick.html
|
|
|
|
|
proto.implode = function implode (factor) { |
|
|
|
|
return this.arg(null, ["-implode", factor || 1]); |
|
|
|
|
return this.out("-implode", factor || 1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// http://www.graphicsmagick.org/GraphicsMagick.html#details-comment
|
|
|
|
@ -196,18 +197,18 @@ module.exports = function (proto) { |
|
|
|
|
return this; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return this.arg(null, ["-limit", type, val]); |
|
|
|
|
return this.out("-limit", type, val); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// http://www.graphicsmagick.org/GraphicsMagick.html
|
|
|
|
|
proto.median = function median (radius) { |
|
|
|
|
return this.arg(null, ["-median", radius || 1]); |
|
|
|
|
return this.out("-median", radius || 1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// http://www.graphicsmagick.org/GraphicsMagick.html#details-negate
|
|
|
|
|
proto.negative = function negative (grayscale) { |
|
|
|
|
var sign = grayscale ? "+" : "-"; |
|
|
|
|
return this.arg(null, [sign + "negate"]); |
|
|
|
|
return this.out(sign + "negate"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var noises = [ |
|
|
|
@ -226,22 +227,22 @@ module.exports = function (proto) { |
|
|
|
|
? "+" |
|
|
|
|
: "-"; |
|
|
|
|
|
|
|
|
|
return this.arg(null, [sign + "noise", radius]); |
|
|
|
|
return this.out(sign + "noise", radius); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// http://www.graphicsmagick.org/GraphicsMagick.html#details-paint
|
|
|
|
|
proto.paint = function paint (radius) { |
|
|
|
|
return this.arg(null, ["-paint", radius]); |
|
|
|
|
return this.out("-paint", radius); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// http://www.graphicsmagick.org/GraphicsMagick.html#details-raise
|
|
|
|
|
proto.raise = function raise (w, h) { |
|
|
|
|
return this.arg(null, ["-raise", (w||0)+"x"+(h||0)]); |
|
|
|
|
return this.out("-raise", (w||0)+"x"+(h||0)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// http://www.graphicsmagick.org/GraphicsMagick.html#details-raise
|
|
|
|
|
proto.lower = function lower (w, h) { |
|
|
|
|
return this.arg(null, ["+raise", (w||0)+"x"+(h||0)]); |
|
|
|
|
return this.out("+raise", (w||0)+"x"+(h||0)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// http://www.graphicsmagick.org/GraphicsMagick.html#details-region
|
|
|
|
@ -250,14 +251,14 @@ module.exports = function (proto) { |
|
|
|
|
h = h || 0; |
|
|
|
|
x = x || 0; |
|
|
|
|
y = y || 0; |
|
|
|
|
return this.arg(null, ["-region", w + "x" + h + "+" + x + "+" + y]); |
|
|
|
|
return this.out("-region", w + "x" + h + "+" + x + "+" + y); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// http://www.graphicsmagick.org/GraphicsMagick.html#details-roll
|
|
|
|
|
proto.roll = function roll (x, y) { |
|
|
|
|
x = ((x = parseInt(x, 10) || 0) > 0 ? "+" : "") + x; |
|
|
|
|
y = ((y = parseInt(y, 10) || 0) > 0 ? "+" : "") + y; |
|
|
|
|
return this.arg(null, ["-roll", x+y]); |
|
|
|
|
return this.out("-roll", x+y); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// http://www.graphicsmagick.org/GraphicsMagick.html#details-sharpen
|
|
|
|
@ -266,27 +267,27 @@ module.exports = function (proto) { |
|
|
|
|
? "x" + sigma |
|
|
|
|
: ""; |
|
|
|
|
|
|
|
|
|
return this.arg(null, ["-sharpen", radius + sigma]); |
|
|
|
|
return this.out("-sharpen", radius + sigma); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// http://www.graphicsmagick.org/GraphicsMagick.html#details-solarize
|
|
|
|
|
proto.solarize = function solarize (factor) { |
|
|
|
|
return this.arg(null, ["-solarize", (factor || 1)+"%"]); |
|
|
|
|
return this.out("-solarize", (factor || 1)+"%"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// http://www.graphicsmagick.org/GraphicsMagick.html#details-spread
|
|
|
|
|
proto.spread = function spread (amount) { |
|
|
|
|
return this.arg(null, ["-spread", amount || 5]); |
|
|
|
|
return this.out("-spread", amount || 5); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// http://www.graphicsmagick.org/GraphicsMagick.html#details-swirl
|
|
|
|
|
proto.swirl = function swirl (degrees) { |
|
|
|
|
return this.arg(null, ["-swirl", degrees || 180]); |
|
|
|
|
return this.out("-swirl", degrees || 180); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// http://www.graphicsmagick.org/GraphicsMagick.html#details-type
|
|
|
|
|
proto.type = function type (type) { |
|
|
|
|
return this.arg(["-type", type]); |
|
|
|
|
return this.in("-type", type); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
@ -302,6 +303,6 @@ function comment (arg) { |
|
|
|
|
? format.substring(1) |
|
|
|
|
: format; |
|
|
|
|
|
|
|
|
|
return this.arg(null, [arg, '"' + format + '"']); |
|
|
|
|
return this.out(arg, '"' + format + '"'); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|