@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
55 lines (51 loc) • 1.52 kB
JavaScript
;
var Action = require('./Action-34aa7481.cjs');
var Qualifier = require('./Qualifier-6633a22f.cjs');
/**
* @description Uses generative AI to replace parts of your image with something else.
* @extends SDK.Action
* @memberOf Actions.Effect
* @see Visit {@link Actions.Effect|Effect} for an example
*/
class GenerativeReplace extends Action.Action {
constructor() {
super();
this._preserveGeometry = false;
this._actionModel.actionType = "generativeReplace";
}
from(value) {
this._from = value;
this._actionModel.from = value;
return this;
}
to(value) {
this._to = value;
this._actionModel.to = value;
return this;
}
preserveGeometry(value = true) {
this._preserveGeometry = value;
if (value) {
this._actionModel.preserveGeometry = true;
}
return this;
}
prepareQualifiers() {
let str = `gen_replace:from_${this._from};to_${this._to}`;
if (this._preserveGeometry) {
str += `;preserve-geometry_true`;
}
this.addQualifier(new Qualifier.Qualifier("e", str));
}
static fromJson(actionModel) {
const { from, to, preserveGeometry } = actionModel;
const result = new this();
result.from(from);
result.to(to);
if (preserveGeometry) {
result.preserveGeometry();
}
return result;
}
}
exports.GenerativeReplace = GenerativeReplace;