executeRemoveBg method
Future<String>
executeRemoveBg(
- String fileId, {
- bool? crop,
- String? cropMargin,
- String? scale,
- bool? addShadow,
- RemoveBgTypeLevelValue? typeLevel,
- RemoveBgTypeValue? type,
- bool? semitransparency,
- RemoveBgChannelsValue? channels,
- String? roi,
- String? position,
Execute remove.bg background image removal Add-On for a given target.
See https://uploadcare.com/api-refs/rest-api/v0.7.0/#operation/removeBgExecute
Implementation
Future<String> executeRemoveBg(
String fileId, {
/// Whether to crop off all empty regions
/// Default: false
bool? crop,
/// Adds a margin around the cropped subject, e.g 30px or 30%
/// Default: '0'
String? cropMargin,
/// Scales the subject relative to the total image size, e.g 80%
String? scale,
/// Whether to add an artificial shadow to the result
/// Default: false
bool? addShadow,
/// Default: 'none'
RemoveBgTypeLevelValue? typeLevel,
/// Foreground type.
RemoveBgTypeValue? type,
/// Whether to have semi-transparent regions in the result
/// Default: true
bool? semitransparency,
/// Request either the finalized image ('rgba', default) or an alpha mask ('alpha').
/// Default: 'rgba'
RemoveBgChannelsValue? channels,
/// Region of interest: Only contents of this rectangular region can be detected as foreground.
/// Everything outside is considered background and will be removed.
/// The rectangle is defined as two x/y coordinates in the format "x1 y1 x2 y2".
/// The coordinates can be in absolute pixels (suffix 'px') or relative to the width/height of the image (suffix '%').
/// By default, the whole image is the region of interest ("0% 0% 100% 100%").
String? roi,
/// Positions the subject within the image canvas.
/// Can be "original" (default unless "scale" is given), "center" (default when "scale" is given) or a value from "0%" to "100%" (both horizontal and vertical) or two values (horizontal, vertical).
String? position,
}) async {
final params = <String, String>{
if (crop != null) 'crop': crop.toString(),
if (cropMargin != null) 'crop_margin': cropMargin,
if (scale != null) 'scale': scale,
if (addShadow != null) 'add_shadow': addShadow.toString(),
if (typeLevel != null) 'type_level': typeLevel.toString(),
if (type != null) 'type': type.toString(),
if (semitransparency != null)
'semitransparency': semitransparency.toString(),
if (channels != null) 'channels': channels.toString(),
if (roi != null) 'roi': roi,
if (position != null) 'position': position,
};
return await _execute(
pathname: '/addons/remove_bg/execute/',
params: {
'target': fileId,
if (params.isNotEmpty) 'params': params,
},
);
}