如何在视频/图像上添加图像或文本(水印)-Flutter / Dart

我正在构建一个Flutter应用程序,该应用程序需要在视频和图像上添加标记。 有什么方法可以通过firebase(或任何其他服务)来实现?我可以在client-side上执行此操作,但在那里也找不到与视频/图像处理相关的任何flutter / Dart程序包。

请指导我如何做。

谢谢

chen_004488 回答:如何在视频/图像上添加图像或文本(水印)-Flutter / Dart

对于视频:

对于图像:

对于其他服务,我不知道,但是Firebase不提供此服务。

否则,在客户端/应用程序端,视频的其他内容很少,但是图像的内容更多,您可以搜索https://pub.dev/flutter/packages?q=image+editor。但是,要获得更多选择,您必须寻找Android / iOS本机库和custom integrate them through the platform channels

,

我不确定要在视频上添加水印。但是,要帮助正在图像上寻找水印的人们,可以参考我写的简单文章。

Add Watermark over Image in Flutter

在本文中,我使用Image包在Image上应用水印文本或图像。关于此主题的示例程序也得到了很好的解释。

,

对于水印图像:

import 'package:extended_image/extended_image.dart';
import 'package:image/image.dart' as ui;
import 'package:path_provider/path_provider.dart';


Future<File> watermarkPicture( File picture,File watermark,String fileName) async {
  ui.Image originalImage = ui.decodeImage(picture.readAsBytesSync());
  ui.Image watermarkImage = ui.decodeImage((watermark.readAsBytesSync()));

  ui.Image image = ui.Image(originalImage.width,originalImage.height);
  ui.drawImage(image,watermarkImage);

  // Easy customisation for the position of the watermark in the next two lines
  final int positionX = (originalImage.width / 2 - watermarkImage.width / 2).toInt();
  final int positionY = (originalImage.height - watermarkImage.height * 1.15).toInt();

  ui.copyInto(
    originalImage,image,dstX: positionX,dstY: positionY,);
  final File watermarkedFile = File('${(await getTemporaryDirectory()).path}/$fileName');

  await watermarkedFile.writeAsBytes(ui.encodeJpg(originalImage));

  return watermarkedFile;
}

这是对 medium article 的定制。因为原来的解决方案对我不起作用。

本文链接:https://www.f2er.com/3152694.html

大家都在问