/**
* 去除图片水印
*/
@Test
public void deleteLogo(){
/**
* 对delogo滤镜的说明:
- x,y:水印的左上方坐标
- w,h: 水印的宽高
- show: 可选参数,调试使用, 为1时,可以看到一个绿色的由x,y,w,h所确认的矩形框。调试完成后将参数改为0即可。
*/
// 命令
String commit = " $0 -i $1 -strict -2 -vf delogo=x=620:y=858:w=75:h=40:show=1 $2";
// ffmpeg
String ffmpegPath = "D:\\Java\\operSources\\ffmpeg-4.3.1\\bin\\ffmpeg.exe";
String str = commit.replace("$0", ffmpegPath)
.replace("$1", "D:\\image\\原图.jpg")
.replace("$2", "D:\\image\\修改后.jpg");
System.out.println(str);
Runtime runtime = Runtime.getRuntime();
try {
Process proce = runtime.exec(str);
} catch (IOException e) {
e.printStackTrace();
}
}
原图
调试图(参数: show=1)
结果图(参数: show=0)