@cloudinary/url-gen
Version:
Cloudinary URL-Gen SDK ========================= [](https://app.travis-ci.com/github/cloudinary/js-url-gen) ## About The Cloudinary URL-Gen SDK allows you to quickly and eas
61 lines (57 loc) • 1.98 kB
JavaScript
;
var Action = require('./Action-34aa7481.cjs');
var QualifierValue = require('./QualifierValue-e770d619.cjs');
var Qualifier = require('./Qualifier-6633a22f.cjs');
/**
* @description A class that defines how to remove the background of an asset
* @extends SDK.Action
* @memberOf Actions.Effect
* @see Visit {@link Actions.Effect|Effect} for an example
*/
class BackgroundRemoval extends Action.Action {
constructor() {
super();
this._actionModel.actionType = 'backgroundRemoval';
}
fineEdges(value = true) {
this._fineEdges = value;
this._actionModel.fineEdges = this._fineEdges;
return this;
}
hints(...values) {
if (values.length === 1 && Array.isArray(values[0])) {
// Handle the case of a single array argument
this._hints = values[0];
}
else if (values.length) {
this._hints = values;
}
if (this._hints) {
this._actionModel.hints = this._hints;
}
return this;
}
prepareQualifiers() {
var _a;
let str = 'background_removal';
if (this._fineEdges !== undefined) {
str += `:${new QualifierValue.QualifierValue(`fineedges_${this._fineEdges ? 'y' : 'n'}`).toString()}`;
}
if ((_a = this._hints) === null || _a === void 0 ? void 0 : _a.length) {
str += `:${new QualifierValue.QualifierValue(`hints_(${this._hints.join(';')})`).toString()}`;
}
this.addQualifier(new Qualifier.Qualifier('e', str));
}
static fromJson(actionModel) {
const { fineEdges, hints } = actionModel;
const result = new this();
if (fineEdges !== undefined) {
result.fineEdges(fineEdges);
}
if (hints === null || hints === void 0 ? void 0 : hints.length) {
result.hints(hints);
}
return result;
}
}
exports.BackgroundRemoval = BackgroundRemoval;