1 |
|
2 |
|
3 |
|
4 |
|
5 | var argsToArray = require('./utils').argsToArray;
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | module.exports = function (proto) {
|
12 |
|
13 |
|
14 | proto.selectFrame = function (frame) {
|
15 | if (typeof frame === 'number')
|
16 | this.sourceFrames = '[' + frame + ']';
|
17 | return this;
|
18 | }
|
19 |
|
20 |
|
21 | proto.command = proto.subCommand = function subCommand (name){
|
22 | this._subCommand = name;
|
23 | return this;
|
24 | }
|
25 |
|
26 |
|
27 | proto.adjoin = function adjoin () {
|
28 | return this.out("-adjoin");
|
29 | }
|
30 |
|
31 |
|
32 | proto.affine = function affine (matrix) {
|
33 | return this.out("-affine", matrix);
|
34 | }
|
35 |
|
36 | |
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 | proto.append = function append (img, ltr) {
|
62 | if (!this._append) {
|
63 | this._append = [];
|
64 | this.addSrcFormatter(function (src) {
|
65 | this.out(this._append.ltr ? '+append' : '-append');
|
66 | src.push.apply(src, this._append);
|
67 | });
|
68 | }
|
69 |
|
70 | if (0 === arguments.length) {
|
71 | this._append.ltr = false;
|
72 | return this;
|
73 | }
|
74 |
|
75 | for (var i = 0; i < arguments.length; ++i) {
|
76 | var arg = arguments[i];
|
77 | switch (typeof arg) {
|
78 | case 'boolean':
|
79 | this._append.ltr = arg;
|
80 | break;
|
81 | case 'string':
|
82 | this._append.push(arg);
|
83 | break;
|
84 | }
|
85 | }
|
86 |
|
87 | return this;
|
88 | }
|
89 |
|
90 |
|
91 | proto.authenticate = function authenticate (string) {
|
92 | return this.out("-authenticate", string);
|
93 | }
|
94 |
|
95 |
|
96 | proto.average = function average () {
|
97 | return this.out("-average");
|
98 | }
|
99 |
|
100 |
|
101 | proto.backdrop = function backdrop () {
|
102 | return this.out("-backdrop");
|
103 | }
|
104 |
|
105 |
|
106 | proto.blackThreshold = function blackThreshold (red, green, blue, opacity) {
|
107 | return this.out("-black-threshold", argsToArray(red, green, blue, opacity).join(','));
|
108 | }
|
109 |
|
110 |
|
111 | proto.bluePrimary = function bluePrimary (x, y) {
|
112 | return this.out("-blue-primary", argsToArray(x, y).join(','));
|
113 | }
|
114 |
|
115 |
|
116 | proto.border = function border (width, height) {
|
117 | return this.out("-border", width+"x"+height);
|
118 | }
|
119 |
|
120 |
|
121 | proto.borderColor = function borderColor (color) {
|
122 | return this.out("-bordercolor", color);
|
123 | }
|
124 |
|
125 |
|
126 | proto.box = function box (color) {
|
127 | return this.out("-box", color);
|
128 | }
|
129 |
|
130 |
|
131 | proto.channel = function channel (type) {
|
132 | return this.out("-channel", type);
|
133 | }
|
134 |
|
135 |
|
136 | proto.chop = function chop (w, h, x, y) {
|
137 | return this.in("-chop", w+"x"+h + "+"+(x||0)+"+"+(y||0));
|
138 | }
|
139 |
|
140 |
|
141 | proto.clip = function clip () {
|
142 | return this.out("-clip");
|
143 | }
|
144 |
|
145 |
|
146 | proto.coalesce = function coalesce () {
|
147 | return this.out("-coalesce");
|
148 | }
|
149 |
|
150 |
|
151 | proto.colorize = function colorize (r, g, b) {
|
152 | return this.out("-colorize", [r,g,b].join(","));
|
153 | }
|
154 |
|
155 |
|
156 | proto.colorMap = function colorMap (type) {
|
157 | return this.out("-colormap", type);
|
158 | }
|
159 |
|
160 |
|
161 | proto.compose = function compose (operator) {
|
162 | return this.out("-compose", operator);
|
163 | }
|
164 |
|
165 |
|
166 | proto.compress = function compress (type) {
|
167 | return this.out("-compress", type);
|
168 | }
|
169 |
|
170 |
|
171 | proto.convolve = function convolve (kernel) {
|
172 | return this.out("-convolve", kernel);
|
173 | }
|
174 |
|
175 |
|
176 | proto.createDirectories = function createDirectories () {
|
177 | return this.out("-create-directories");
|
178 | }
|
179 |
|
180 |
|
181 | proto.deconstruct = function deconstruct () {
|
182 | return this.out("-deconstruct");
|
183 | }
|
184 |
|
185 |
|
186 | proto.define = function define (value) {
|
187 | return this.out("-define", value);
|
188 | }
|
189 |
|
190 |
|
191 | proto.delay = function delay (value) {
|
192 | return this.out("-delay", value);
|
193 | }
|
194 |
|
195 |
|
196 | proto.displace = function displace (horizontalScale, verticalScale) {
|
197 | return this.out("-displace", horizontalScale+'x'+verticalScale);
|
198 | }
|
199 |
|
200 |
|
201 | proto.display = function display (value) {
|
202 | return this.out("-display", value);
|
203 | }
|
204 |
|
205 |
|
206 | proto.dispose = function dispose (method) {
|
207 | return this.out("-dispose", method);
|
208 | }
|
209 |
|
210 |
|
211 | proto.encoding = function encoding (type) {
|
212 | return this.out("-encoding", type);
|
213 | }
|
214 |
|
215 |
|
216 | proto.endian = function endian (type) {
|
217 | return this.out("-endian", type);
|
218 | }
|
219 |
|
220 |
|
221 | proto.file = function file (filename) {
|
222 | return this.out("-file", filename);
|
223 | }
|
224 |
|
225 |
|
226 | proto.flatten = function flatten () {
|
227 | return this.out("-flatten");
|
228 | }
|
229 |
|
230 |
|
231 | proto.foreground = function foreground (color) {
|
232 | return this.out("-foreground", color);
|
233 | }
|
234 |
|
235 |
|
236 | proto.frame = function frame (width, height, outerBevelWidth, innerBevelWidth) {
|
237 | if(arguments.length==0) return this.out("-frame");
|
238 | return this.out("-frame", width+'x'+height+'+'+outerBevelWidth+'+'+innerBevelWidth);
|
239 | }
|
240 |
|
241 |
|
242 | proto.fuzz = function fuzz (distance, percent) {
|
243 | return this.out("-fuzz", distance+(percent?'%':''));
|
244 | }
|
245 |
|
246 |
|
247 | proto.gaussian = function gaussian (radius, sigma) {
|
248 | return this.out("-gaussian", argsToArray(radius, sigma).join('x'));
|
249 | }
|
250 |
|
251 |
|
252 | proto.geometry = function geometry (width, height, arg) {
|
253 | return this.out("-geometry", width+'x'+height+(arg||''));
|
254 | }
|
255 |
|
256 |
|
257 | proto.greenPrimary = function greenPrimary (x, y) {
|
258 | return this.out("-green-primary", x+','+y);
|
259 | }
|
260 |
|
261 |
|
262 | proto.highlightColor = function highlightColor (color) {
|
263 | return this.out("-highlight-color", color);
|
264 | }
|
265 |
|
266 |
|
267 | proto.highlightStyle = function highlightStyle (style) {
|
268 | return this.out("-highlight-style", style);
|
269 | }
|
270 |
|
271 |
|
272 | proto.iconGeometry = function iconGeometry (geometry) {
|
273 | return this.out("-iconGeometry", geometry);
|
274 | }
|
275 |
|
276 |
|
277 | proto.intent = function intent (type) {
|
278 | return this.out("-intent", type);
|
279 | }
|
280 |
|
281 |
|
282 | proto.lat = function lat (width, height, offset, percent) {
|
283 | return this.out("-lat", width+'x'+height+offset+(percent?'%':''));
|
284 | }
|
285 |
|
286 |
|
287 | proto.level = function level (blackPoint, gamma, whitePoint, percent) {
|
288 | return this.out("-level", argsToArray(blackPoint, gamma, whitePoint).join(',')+(percent?'%':''));
|
289 | }
|
290 |
|
291 |
|
292 | proto.list = function list (type) {
|
293 | return this.out("-list", type);
|
294 | }
|
295 |
|
296 |
|
297 | proto.log = function log (string) {
|
298 | return this.out("-log", string);
|
299 | }
|
300 |
|
301 |
|
302 | proto.loop = function loop (iterations) {
|
303 | return this.out("-loop", iterations);
|
304 | }
|
305 |
|
306 |
|
307 | proto.map = function map (filename) {
|
308 | return this.out("-map", filename);
|
309 | }
|
310 |
|
311 |
|
312 | proto.mask = function mask (filename) {
|
313 | return this.out("-mask", filename);
|
314 | }
|
315 |
|
316 |
|
317 | proto.matte = function matte () {
|
318 | return this.out("-matte");
|
319 | }
|
320 |
|
321 |
|
322 | proto.matteColor = function matteColor (color) {
|
323 | return this.out("-mattecolor", color);
|
324 | }
|
325 |
|
326 |
|
327 | proto.maximumError = function maximumError (limit) {
|
328 | return this.out("-maximum-error", limit);
|
329 | }
|
330 |
|
331 |
|
332 | proto.mode = function mode (value) {
|
333 | return this.out("-mode", value);
|
334 | }
|
335 |
|
336 |
|
337 | proto.monitor = function monitor () {
|
338 | return this.out("-monitor");
|
339 | }
|
340 |
|
341 |
|
342 | proto.mosaic = function mosaic () {
|
343 | return this.out("-mosaic");
|
344 | }
|
345 |
|
346 |
|
347 | proto.motionBlur = function motionBlur (radius, sigma, angle) {
|
348 | var arg=radius;
|
349 | if (typeof sigma!='undefined') arg+='x'+sigma;
|
350 | if (typeof angle!='undefined') arg+='+'+angle;
|
351 | return this.out("-motion-blur", arg);
|
352 | }
|
353 |
|
354 |
|
355 | proto.name = function name () {
|
356 | return this.out("-name");
|
357 | }
|
358 |
|
359 |
|
360 | proto.noop = function noop () {
|
361 | return this.out("-noop");
|
362 | }
|
363 |
|
364 |
|
365 | proto.normalize = function normalize () {
|
366 | return this.out("-normalize");
|
367 | }
|
368 |
|
369 |
|
370 | proto.opaque = function opaque (color) {
|
371 | return this.out("-opaque", color);
|
372 | }
|
373 |
|
374 |
|
375 | proto.operator = function operator (channel, operator, rvalue, percent) {
|
376 | return this.out("-operator", channel, operator, rvalue+(percent?'%':''));
|
377 | }
|
378 |
|
379 |
|
380 | proto.orderedDither = function orderedDither (channeltype, NxN) {
|
381 | return this.out("-ordered-dither", channeltype, NxN);
|
382 | }
|
383 |
|
384 |
|
385 | proto.outputDirectory = function outputDirectory (directory) {
|
386 | return this.out("-output-directory", directory);
|
387 | }
|
388 |
|
389 |
|
390 | proto.page = function page (width, height, arg) {
|
391 | return this.out("-page", width+'x'+height+(arg||''));
|
392 | }
|
393 |
|
394 |
|
395 | proto.pause = function pause (seconds) {
|
396 | return this.out("-pause", seconds);
|
397 | }
|
398 |
|
399 |
|
400 | proto.pen = function pen (color) {
|
401 | return this.out("-pen", color);
|
402 | }
|
403 |
|
404 |
|
405 | proto.ping = function ping () {
|
406 | return this.out("-ping");
|
407 | }
|
408 |
|
409 |
|
410 | proto.pointSize = function pointSize (value) {
|
411 | return this.out("-pointsize", value);
|
412 | }
|
413 |
|
414 |
|
415 | proto.preview = function preview (type) {
|
416 | return this.out("-preview", type);
|
417 | }
|
418 |
|
419 |
|
420 | proto.process = function process (command) {
|
421 | return this.out("-process", command);
|
422 | }
|
423 |
|
424 |
|
425 | proto.profile = function profile (filename) {
|
426 | return this.out("-profile", filename);
|
427 | }
|
428 |
|
429 |
|
430 | proto.progress = function progress () {
|
431 | return this.out("+progress");
|
432 | }
|
433 |
|
434 |
|
435 | proto.randomThreshold = function randomThreshold (channeltype, LOWxHIGH) {
|
436 | return this.out("-random-threshold", channeltype, LOWxHIGH);
|
437 | }
|
438 |
|
439 |
|
440 | proto.recolor = function recolor (matrix) {
|
441 | return this.out("-recolor", matrix);
|
442 | }
|
443 |
|
444 |
|
445 | proto.redPrimary = function redPrimary (x, y) {
|
446 | return this.out("-red-primary", x, y);
|
447 | }
|
448 |
|
449 |
|
450 | proto.remote = function remote () {
|
451 | return this.out("-remote");
|
452 | }
|
453 |
|
454 |
|
455 | proto.render = function render () {
|
456 | return this.out("-render");
|
457 | }
|
458 |
|
459 |
|
460 | proto.repage = function repage (width, height, xoff, yoff, arg) {
|
461 | return this.out("-repage", width+'x'+height+'+'+xoff+'+'+yoff+(arg||''));
|
462 | }
|
463 |
|
464 |
|
465 | proto.sample = function sample (geometry) {
|
466 | return this.out("-sample", geometry);
|
467 | }
|
468 |
|
469 |
|
470 | proto.samplingFactor = function samplingFactor (horizontalFactor, verticalFactor) {
|
471 | return this.out("-sampling-factor", horizontalFactor+'x'+verticalFactor);
|
472 | }
|
473 |
|
474 |
|
475 | proto.scene = function scene (value) {
|
476 | return this.out("-scene", value);
|
477 | }
|
478 |
|
479 |
|
480 | proto.scenes = function scenes (start, end) {
|
481 | return this.out("-scenes", start+'-'+end);
|
482 | }
|
483 |
|
484 |
|
485 | proto.screen = function screen () {
|
486 | return this.out("-screen");
|
487 | }
|
488 |
|
489 |
|
490 | proto.set = function set (attribute, value) {
|
491 | return this.out("-set", attribute, value);
|
492 | }
|
493 |
|
494 |
|
495 | proto.segment = function segment (clusterThreshold, smoothingThreshold) {
|
496 | return this.out("-segment", clusterThreshold+'x'+smoothingThreshold);
|
497 | }
|
498 |
|
499 |
|
500 | proto.shade = function shade (azimuth, elevation) {
|
501 | return this.out("-shade", azimuth+'x'+elevation);
|
502 | }
|
503 |
|
504 |
|
505 | proto.shadow = function shadow (radius, sigma) {
|
506 | return this.out("-shadow", argsToArray(radius, sigma).join('x'));
|
507 | }
|
508 |
|
509 |
|
510 | proto.sharedMemory = function sharedMemory () {
|
511 | return this.out("-shared-memory");
|
512 | }
|
513 |
|
514 |
|
515 | proto.shave = function shave (width, height, percent) {
|
516 | return this.out("-shave", width+'x'+height+(percent?'%':''));
|
517 | }
|
518 |
|
519 |
|
520 | proto.shear = function shear (xDegrees, yDegreees) {
|
521 | return this.out("-shear", xDegrees+'x'+yDegreees);
|
522 | }
|
523 |
|
524 |
|
525 | proto.silent = function silent (color) {
|
526 | return this.out("-silent");
|
527 | }
|
528 |
|
529 |
|
530 | proto.rawSize = function rawSize (width, height, offset) {
|
531 | var off = 'undefined' != typeof offset
|
532 | ? '+' + offset
|
533 | : '';
|
534 | return this.out("-size", width +'x'+ height + off);
|
535 | }
|
536 |
|
537 |
|
538 | proto.snaps = function snaps (value) {
|
539 | return this.out("-snaps", value);
|
540 | }
|
541 |
|
542 |
|
543 | proto.stegano = function stegano (offset) {
|
544 | return this.out("-stegano", offset);
|
545 | }
|
546 |
|
547 |
|
548 | proto.stereo = function stereo () {
|
549 | return this.out("-stereo");
|
550 | }
|
551 |
|
552 |
|
553 | proto.textFont = function textFont (name) {
|
554 | return this.out("-text-font", name);
|
555 | }
|
556 |
|
557 |
|
558 | proto.texture = function texture (filename) {
|
559 | return this.out("-texture", filename);
|
560 | }
|
561 |
|
562 |
|
563 | proto.threshold = function threshold (value, percent) {
|
564 | return this.out("-threshold", value+(percent?'%':''));
|
565 | }
|
566 |
|
567 |
|
568 | proto.thumbnail = function thumbnail (width, height) {
|
569 | return this.out("-thumbnail", width + "x" + height);
|
570 | }
|
571 |
|
572 |
|
573 | proto.tile = function tile (filename) {
|
574 | return this.out("-tile", filename);
|
575 | }
|
576 |
|
577 |
|
578 | proto.title = function title (string) {
|
579 | return this.out("-title", string);
|
580 | }
|
581 |
|
582 |
|
583 | proto.transform = function transform (color) {
|
584 | return this.out("-transform", color);
|
585 | }
|
586 |
|
587 |
|
588 | proto.transparent = function transparent (color) {
|
589 | return this.out("-transparent", color);
|
590 | }
|
591 |
|
592 |
|
593 | proto.treeDepth = function treeDepth (value) {
|
594 | return this.out("-treedepth", value);
|
595 | }
|
596 |
|
597 |
|
598 | proto.update = function update (seconds) {
|
599 | return this.out("-update", seconds);
|
600 | }
|
601 |
|
602 |
|
603 | proto.units = function units (type) {
|
604 | return this.out("-units", type);
|
605 | }
|
606 |
|
607 |
|
608 | proto.unsharp = function unsharp (radius, sigma, amount, threshold) {
|
609 | var arg=radius;
|
610 | if (typeof sigma != 'undefined') arg+='x'+sigma;
|
611 | if (typeof amount != 'undefined') arg+='+'+amount;
|
612 | if (typeof threshold != 'undefined') arg+='+'+threshold;
|
613 | return this.out("-unsharp", arg);
|
614 | }
|
615 |
|
616 |
|
617 | proto.usePixmap = function usePixmap () {
|
618 | return this.out("-use-pixmap");
|
619 | }
|
620 |
|
621 |
|
622 | proto.view = function view (string) {
|
623 | return this.out("-view", string);
|
624 | }
|
625 |
|
626 |
|
627 | proto.virtualPixel = function virtualPixel (method) {
|
628 | return this.out("-virtual-pixel", method);
|
629 | }
|
630 |
|
631 |
|
632 | proto.visual = function visual (type) {
|
633 | return this.out("-visual", type);
|
634 | }
|
635 |
|
636 |
|
637 | proto.watermark = function watermark (brightness, saturation) {
|
638 | return this.out("-watermark", brightness+'x'+saturation);
|
639 | }
|
640 |
|
641 |
|
642 | proto.wave = function wave (amplitude, wavelength) {
|
643 | return this.out("-wave", amplitude+'x'+wavelength);
|
644 | }
|
645 |
|
646 |
|
647 | proto.whitePoint = function whitePoint (x, y) {
|
648 | return this.out("-white-point", x+'x'+y);
|
649 | }
|
650 |
|
651 |
|
652 | proto.whiteThreshold = function whiteThreshold (red, green, blue, opacity) {
|
653 | return this.out("-white-threshold", argsToArray(red, green, blue, opacity).join(','));
|
654 | }
|
655 |
|
656 |
|
657 | proto.window = function window (id) {
|
658 | return this.out("-window", id);
|
659 | }
|
660 |
|
661 |
|
662 | proto.windowGroup = function windowGroup () {
|
663 | return this.out("-window-group");
|
664 | }
|
665 |
|
666 |
|
667 | proto.strip = function strip () {
|
668 | if (this._options.imageMagick) return this.out("-strip");
|
669 | return this.noProfile().out("+comment");
|
670 | }
|
671 |
|
672 |
|
673 | proto.interlace = function interlace (type) {
|
674 | return this.out("-interlace", type || "None");
|
675 | }
|
676 |
|
677 |
|
678 | proto.setFormat = function setFormat (format) {
|
679 | if (format) this._outputFormat = format;
|
680 | return this;
|
681 | }
|
682 |
|
683 |
|
684 | proto.resize = function resize (w, h, options) {
|
685 | options = options || "";
|
686 | var geometry;
|
687 | if (w && h) {
|
688 | geometry = w + "x" + h + options
|
689 | } else if (w && !h) {
|
690 |
|
691 | geometry = (this._options.imageMagick) ? w + options : w + 'x' + options;
|
692 | } else if (!w && h) {
|
693 | geometry = 'x' + h + options
|
694 | }
|
695 |
|
696 | return this.out("-resize", geometry);
|
697 | }
|
698 |
|
699 |
|
700 | proto.scale = function scale (w, h, options) {
|
701 | options = options || "";
|
702 | var geometry;
|
703 | if (w && h) {
|
704 | geometry = w + "x" + h + options
|
705 | } else if (w && !h) {
|
706 | geometry = (this._options.imageMagick) ? w + options : w + 'x' + options;
|
707 | } else if (!w && h) {
|
708 | geometry = 'x' + h + options
|
709 | }
|
710 |
|
711 | return this.out("-scale", geometry);
|
712 | }
|
713 |
|
714 |
|
715 | proto.filter = function filter (val) {
|
716 | return this.out("-filter", val);
|
717 | }
|
718 |
|
719 |
|
720 | proto.density = function density (w, h) {
|
721 | return this.in("-density", w +"x"+ h);
|
722 | }
|
723 |
|
724 |
|
725 | proto.noProfile = function noProfile () {
|
726 | this.out('+profile', '"*"');
|
727 | return this;
|
728 | }
|
729 |
|
730 |
|
731 | proto.resample = function resample (w, h) {
|
732 | return this.out("-resample", w+"x"+h);
|
733 | }
|
734 |
|
735 |
|
736 | proto.rotate = function rotate (color, deg) {
|
737 | return this.out("-background", color, "-rotate", String(deg || 0));
|
738 | }
|
739 |
|
740 |
|
741 | proto.flip = function flip () {
|
742 | return this.out("-flip");
|
743 | }
|
744 |
|
745 |
|
746 | proto.flop = function flop () {
|
747 | return this.out("-flop");
|
748 | }
|
749 |
|
750 |
|
751 | proto.crop = function crop (w, h, x, y, percent) {
|
752 | if (this.inputIs('jpg')) {
|
753 |
|
754 | var index = this._in.indexOf('-size');
|
755 | if (~index) {
|
756 | this._in.splice(index, 2);
|
757 | }
|
758 | }
|
759 |
|
760 | return this.out("-crop", w + "x" + h + "+" + (x || 0) + "+" + (y || 0) + (percent ? '%' : ''));
|
761 | }
|
762 |
|
763 |
|
764 | proto.magnify = function magnify (factor) {
|
765 | return this.in("-magnify");
|
766 | }
|
767 |
|
768 |
|
769 | proto.minify = function minify () {
|
770 | return this.in("-minify")
|
771 | }
|
772 |
|
773 |
|
774 | proto.quality = function quality (val) {
|
775 | return this.in("-quality", val || 75);
|
776 | }
|
777 |
|
778 |
|
779 | proto.blur = function blur (radius, sigma) {
|
780 | return this.out("-blur", radius + (sigma ? "x"+sigma : ""));
|
781 | }
|
782 |
|
783 |
|
784 | proto.charcoal = function charcoal (factor) {
|
785 | return this.out("-charcoal", factor || 2);
|
786 | }
|
787 |
|
788 |
|
789 | proto.modulate = function modulate (b, s, h) {
|
790 | return this.out("-modulate", [b,s,h].join(","));
|
791 | }
|
792 |
|
793 |
|
794 |
|
795 | proto.antialias = function antialias (disable) {
|
796 | return false === disable
|
797 | ? this.out("+antialias")
|
798 | : this;
|
799 | }
|
800 |
|
801 |
|
802 | proto.bitdepth = function bitdepth (val) {
|
803 | return this.out("-depth", val);
|
804 | }
|
805 |
|
806 |
|
807 | proto.colors = function colors (val) {
|
808 | return this.out("-colors", val || 128);
|
809 | }
|
810 |
|
811 |
|
812 | proto.colorspace = function colorspace (val) {
|
813 | return this.out("-colorspace", val);
|
814 | }
|
815 |
|
816 |
|
817 | proto.comment = comment("-comment");
|
818 |
|
819 |
|
820 | proto.contrast = function contrast (mult) {
|
821 | var arg = (parseInt(mult, 10) || 0) > 0
|
822 | ? "+contrast"
|
823 | : "-contrast";
|
824 |
|
825 | mult = Math.abs(mult) || 1;
|
826 |
|
827 | while (mult--) {
|
828 | this.out(arg);
|
829 | }
|
830 |
|
831 | return this;
|
832 | }
|
833 |
|
834 |
|
835 | proto.cycle = function cycle (amount) {
|
836 | return this.out("-cycle", amount || 2);
|
837 | }
|
838 |
|
839 |
|
840 | proto.despeckle = function despeckle () {
|
841 | return this.out("-despeckle");
|
842 | }
|
843 |
|
844 |
|
845 |
|
846 |
|
847 | proto.dither = function dither (on) {
|
848 | var sign = false === on
|
849 | ? "+"
|
850 | : "-";
|
851 |
|
852 | return this.out(sign + "dither");
|
853 | }
|
854 |
|
855 |
|
856 | proto.monochrome = function monochrome () {
|
857 | return this.out("-monochrome");
|
858 | }
|
859 |
|
860 |
|
861 | proto.edge = function edge (radius) {
|
862 | return this.out("-edge", radius || 1);
|
863 | }
|
864 |
|
865 |
|
866 | proto.emboss = function emboss (radius) {
|
867 | return this.out("-emboss", radius || 1);
|
868 | }
|
869 |
|
870 |
|
871 | proto.enhance = function enhance () {
|
872 | return this.out("-enhance");
|
873 | }
|
874 |
|
875 |
|
876 | proto.equalize = function equalize () {
|
877 | return this.out("-equalize");
|
878 | }
|
879 |
|
880 |
|
881 | proto.gamma = function gamma (r, g, b) {
|
882 | return this.out("-gamma", [r,g,b].join());
|
883 | }
|
884 |
|
885 |
|
886 | proto.implode = function implode (factor) {
|
887 | return this.out("-implode", factor || 1);
|
888 | }
|
889 |
|
890 |
|
891 | proto.label = comment("-label");
|
892 |
|
893 | var limits = [ "disk", "file", "map", "memory", "pixels", "threads"];
|
894 |
|
895 |
|
896 | proto.limit = function limit (type, val) {
|
897 | type = type.toLowerCase();
|
898 |
|
899 | if (!~limits.indexOf(type)) {
|
900 | return this;
|
901 | }
|
902 |
|
903 | return this.out("-limit", type, val);
|
904 | }
|
905 |
|
906 |
|
907 | proto.median = function median (radius) {
|
908 | return this.out("-median", radius || 1);
|
909 | }
|
910 |
|
911 |
|
912 | proto.negative = function negative (grayscale) {
|
913 | var sign = grayscale ? "+" : "-";
|
914 | return this.out(sign + "negate");
|
915 | }
|
916 |
|
917 | var noises = [
|
918 | "uniform"
|
919 | , "gaussian"
|
920 | , "multiplicative"
|
921 | , "impulse"
|
922 | , "laplacian"
|
923 | , "poisson"
|
924 | ];
|
925 |
|
926 |
|
927 | proto.noise = function noise (radius) {
|
928 | radius = (String(radius)).toLowerCase();
|
929 |
|
930 | var sign = ~noises.indexOf(radius)
|
931 | ? "+"
|
932 | : "-";
|
933 |
|
934 | return this.out(sign + "noise", radius);
|
935 | }
|
936 |
|
937 |
|
938 | proto.paint = function paint (radius) {
|
939 | return this.out("-paint", radius);
|
940 | }
|
941 |
|
942 |
|
943 | proto.raise = function raise (w, h) {
|
944 | return this.out("-raise", (w||0)+"x"+(h||0));
|
945 | }
|
946 |
|
947 |
|
948 | proto.lower = function lower (w, h) {
|
949 | return this.out("+raise", (w||0)+"x"+(h||0));
|
950 | }
|
951 |
|
952 |
|
953 | proto.region = function region (w, h, x, y) {
|
954 | w = w || 0;
|
955 | h = h || 0;
|
956 | x = x || 0;
|
957 | y = y || 0;
|
958 | return this.out("-region", w + "x" + h + "+" + x + "+" + y);
|
959 | }
|
960 |
|
961 |
|
962 | proto.roll = function roll (x, y) {
|
963 | x = ((x = parseInt(x, 10) || 0) >= 0 ? "+" : "") + x;
|
964 | y = ((y = parseInt(y, 10) || 0) >= 0 ? "+" : "") + y;
|
965 | return this.out("-roll", x+y);
|
966 | }
|
967 |
|
968 |
|
969 | proto.sharpen = function sharpen (radius, sigma) {
|
970 | sigma = sigma
|
971 | ? "x" + sigma
|
972 | : "";
|
973 |
|
974 | return this.out("-sharpen", radius + sigma);
|
975 | }
|
976 |
|
977 |
|
978 | proto.solarize = function solarize (factor) {
|
979 | return this.out("-solarize", (factor || 1)+"%");
|
980 | }
|
981 |
|
982 |
|
983 | proto.spread = function spread (amount) {
|
984 | return this.out("-spread", amount || 5);
|
985 | }
|
986 |
|
987 |
|
988 | proto.swirl = function swirl (degrees) {
|
989 | return this.out("-swirl", degrees || 180);
|
990 | }
|
991 |
|
992 |
|
993 | proto.type = function type (type) {
|
994 | return this.in("-type", type);
|
995 | }
|
996 |
|
997 |
|
998 | proto.trim = function trim () {
|
999 | return this.out("-trim");
|
1000 | }
|
1001 |
|
1002 |
|
1003 | proto.extent = function extent (w, h, options) {
|
1004 | options = options || "";
|
1005 | var geometry;
|
1006 | if (w && h) {
|
1007 | geometry = w + "x" + h + options
|
1008 | } else if (w && !h) {
|
1009 | geometry = (this._options.imageMagick) ? w + options : w + 'x' + options;
|
1010 | } else if (!w && h) {
|
1011 | geometry = 'x' + h + options
|
1012 | }
|
1013 |
|
1014 | return this.out("-extent", geometry);
|
1015 | }
|
1016 |
|
1017 |
|
1018 |
|
1019 | proto.gravity = function gravity (type) {
|
1020 | if (!type || !~gravity.types.indexOf(type)) {
|
1021 | type = "NorthWest";
|
1022 | }
|
1023 |
|
1024 | return this.out("-gravity", type);
|
1025 | }
|
1026 |
|
1027 | proto.gravity.types = [
|
1028 | "NorthWest"
|
1029 | , "North"
|
1030 | , "NorthEast"
|
1031 | , "West"
|
1032 | , "Center"
|
1033 | , "East"
|
1034 | , "SouthWest"
|
1035 | , "South"
|
1036 | , "SouthEast"
|
1037 | ];
|
1038 |
|
1039 |
|
1040 | proto.flatten = function flatten () {
|
1041 | return this.out("-flatten");
|
1042 | }
|
1043 |
|
1044 |
|
1045 | proto.background = function background (color) {
|
1046 | return this.in("-background", color);
|
1047 | }
|
1048 | };
|
1049 |
|
1050 |
|
1051 |
|
1052 |
|
1053 |
|
1054 | function comment (arg) {
|
1055 | return function (format) {
|
1056 | format = String(format);
|
1057 |
|
1058 | format = "@" == format.charAt(0)
|
1059 | ? format.substring(1)
|
1060 | : format;
|
1061 |
|
1062 | return this.out(arg, '"' + format + '"');
|
1063 | }
|
1064 | }
|