shikeying
2024-01-30 1a56cbb4cc61382d67be150acb2c3a91a679a808
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package com.walker.openocr.util;
 
import org.apache.commons.codec.binary.Base64;
import org.springframework.util.FileCopyUtils;
 
import java.io.File;
import java.io.IOException;
 
/**
 * 描述:
 * @author 时克英
 * @date 2020年2月18日 下午10:06:57
 */
 
public class FaceUtils {
 
    public static final String getImageBase64(String filePath){
        byte[] fileBytes;
        try {
            fileBytes = FileCopyUtils.copyToByteArray(new File(filePath));
            byte[] fileBase64 = Base64.encodeBase64(fileBytes);
            return new String(fileBase64);
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        }
    }
}