private static List<String> getFilePathListByImage(String url, String localPath, String extension) throws IOException {
        BufferedImage bi = ImageIO.read(url);
        int totalHeight = bi.getHeight();
        int splitSize = (totalHeight / SPLIT_RULE_HEIGHT) + 1;
        List<StringsplitFileNmList = new ArrayList<>();
        for (int i = 0; i < splitSize; i++) {
            String splitFileNm = "fileName_" + i;
            File outputFile = new File(localPath + splitFileNm + "." + extension);
            int ySize = SPLIT_RULE_HEIGHT * i;

            int height = SPLIT_RULE_HEIGHT;
            if ((i + 1) == splitSize) {
                height = totalHeight % SPLIT_RULE_HEIGHT;
            }
            if (height == 0) {
                continue;
            }

            BufferedImage subImage = bi.getSubimage(0, ySize, bi.getWidth(), height);

            ImageIO.write(subImage, extension, outputFile);
            splitFileNmList.add(splitFileNm);
        }
        return splitFileNmList;
    }


'java' 카테고리의 다른 글

bit AND 연산 구현  (0) 2021.08.19
from idx to idx 설정  (0) 2020.04.07
확률을 퍼센트로 줘서 랜덤하게 뽑기  (1) 2018.01.18
Intellij Custom VM Option 넣기  (0) 2017.06.16
JUnit Test property 주입 하기  (0) 2017.04.26

+ Recent posts