Skip to content

Latest commit

 

History

History

img2text

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

目录

  1. 图片转图片
    参数调整
  2. gif转gif
  3. 视频转视频

图片转图片

ImgUtil.java

原图

转换后

    @Test
    public static void imgTest() {
        String inputFile = "F:/123/head.png";
        String outputFile = "F:/123/head_copy.png";
        // String base = "01"; // 替换的字符串
        String base = "@#&$%*o!;.";// 字符串由复杂到简单
        int threshold = 8;// 阈值
        ImgUtil.toTextImg(inputFile, outputFile, base, threshold);
    }

具体参数调整如下图所示:

参数调整

  1. 调整字符大小,颜色
  2. 调整字符间距
  3. 调整字符的区域 (index数值越小,灰度越大)

gif转gif

GifUtil.java

原图

转换后1

原图

转换后1

转换后2

测试代码

    @Test
    public static void gifTest() {
        String srcFile = "F:/123/123.gif";
        String targetFile = "F:/123/123_04.gif";
        String base = "01"; // 替换的字符串
        // String base = "@#&$%*o!;.";// 字符串由复杂到简单
        int threshold = 3;// 阈值
        GifUtil.toTextGif(srcFile, targetFile, base, threshold);
    }

视频转视频

FfmpegUtil.java\VideoUtil.java

没做细致的调整,视频的转换可以调调参数

Watch the video

Watch the video

测试代码

    @Test
    public static void videoTest() {
        String srcVideoPath = "F:/123/123.mp4";
        String tarImagePath = "F:/123/mp/";
        String tarAudioPath = "F:/123/mp/audio.aac";
        String tarVideoPath = "F:/123/1234.mp4";
        VideoUtil.readVideo(srcVideoPath,tarImagePath,tarAudioPath,tarVideoPath);
    }