-2

Is there anyone know how to add camera overlay text or watermark and after capture it save to gallery with that text/watermark. I have attached image given below.

Desired demo image : -

I haven't found any solution on flutter.

Raj Dev
  • 1
  • 3

1 Answers1

0

To add a watermark to an image after capturing it in Flutter, you can use the image package and the flutter_image_compress package.

import 'dart:io';
import 'package:image/image.dart' as img;
import 'package:flutter_image_compress/flutter_image_compress.dart';

Future<void> addWatermark(File imageFile) async {
  // Load the image using the image package
  final image = img.decodeImage(await imageFile.readAsBytes());

  // Add a watermark to the image using the image package
  final watermark = img.decodeImage(await File('path/to/watermark.png').readAsBytes());
  img.drawImage(image, watermark, dstX: image.width - watermark.width - 10, dstY: image.height - watermark.height - 10);

  // Compress the image using the flutter_image_compress package
  final compressedImage = await FlutterImageCompress.compressWithList(
    img.encodeJpg(image, quality: 90),
    quality: 90,
  );

  // Save the compressed image
  final outputFile = await imageFile.create();
  await outputFile.writeAsBytes(compressedImage);
}
sanjay
  • 165
  • 2
  • 12
  • Its not the solution what i'm asking. When camera open then showing text on live camera and after capture it then that text added to that photo! Its my question. – Raj Dev Apr 14 '23 at 10:27