addTextWatermarkUint8List method

  1. @override
Future<Uint8List?> addTextWatermarkUint8List(
  1. Uint8List filePath,
  2. String text,
  3. int x,
  4. int y,
  5. int textSize,
  6. int color,
  7. int? backgroundTextColor,
  8. int? backgroundTextPaddingTop,
  9. int? backgroundTextPaddingBottom,
  10. int? backgroundTextPaddingLeft,
  11. int? backgroundTextPaddingRight,
)
override

Adds a text watermark to the image at the specified location with the given parameters.

Returns a Uint8List representing the watermarked image.

Implementation

@override
Future<Uint8List?> addTextWatermarkUint8List(
  Uint8List filePath,
  String text,
  int x,
  int y,
  int textSize,
  int color,
  int? backgroundTextColor,
  int? backgroundTextPaddingTop,
  int? backgroundTextPaddingBottom,
  int? backgroundTextPaddingLeft,
  int? backgroundTextPaddingRight,
) async {
  final result = await watermarkImageChannel.invokeMethod<String?>(
    'addTextWatermark',
    {
      'text': text,
      'filePath': filePath,
      'x': x,
      'y': y,
      'textSize': textSize,
      'color': color,
      'backgroundTextColor': backgroundTextColor,
      'quality': 100,
      'backgroundTextPaddingTop': backgroundTextPaddingTop,
      'backgroundTextPaddingBottom': backgroundTextPaddingBottom,
      'backgroundTextPaddingLeft': backgroundTextPaddingLeft,
      'backgroundTextPaddingRight': backgroundTextPaddingRight,
      'imageFormat': ImageFormat.png,
    },
  );
  if (result != null) {
    final resultBytes = await File(result).readAsBytes();
    return resultBytes;
  } else {
    return null;
  }
}