UNPKG

imagemagick-async

Version:
93 lines (78 loc) 1.83 kB
let Path = require('path'); let PathParts = __dirname.split(Path.sep); let index = PathParts.indexOf('imagemagick-async'); let RootDir = PathParts.slice(0, index + 1).join(Path.sep); let Err = require(Path.join(RootDir, 'error.js')); let Validate = require(Path.join(RootDir, 'validate.js')); let Filepath = require(Path.join(RootDir, 'filepath.js')).Filepath; let MaskBaseClass = require(Path.join(Filepath.ModMasksDir(), 'maskbaseclass.js')).MaskBaseClass; //------------------------------ class WhiteMask extends MaskBaseClass { constructor(builder) { super(builder); } /** * @override */ static get Builder() { class Builder { constructor() { this.name = 'WhiteMask'; this.args = {}; } /** * @param {string} str The path of the image file you are modifying. */ source(str) { this.args.source = str; return this; } build() { return new WhiteMask(this); } } return new Builder(); } /** * @override */ Args() { return ['-alpha', 'extract', '-alpha', 'on']; } /** * @override */ Errors() { let params = WhiteMask.Parameters(); let errors = []; let prefix = 'WHITE_MASK_MASK_MOD_ERROR'; let sourceErr = Err.ErrorMessage.Builder .prefix(prefix) .varName('Source') .condition( new Err.StringCondition.Builder(this.args.source) .isempty(false) .isWhitespace(false) .build() ) .build() .String(); if (sourceErr) errors.push(sourceErr); return errors; } /** * @override */ static Parameters() { return { source: { type: 'string', required: true } } } } //--------------------- // EXPORTS exports.WhiteMask = WhiteMask;