이미지 리사이징 수정

main
이범준 11 months ago
parent a3d6a34cd6
commit d62c10df1b

@ -5,6 +5,9 @@ import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -199,6 +202,11 @@ public class AppCmmnUtil {
}
static int MIN_WH = 480;
public static String getResizeImageTempPath(String path, String prefix) throws Exception {
byte[] bytes = resizeImage(path);
return bytesToTempFile(prefix,FilenameUtils.getExtension(path),bytes);
}
public static byte[] resizeImage(String path) throws Exception {
File file = new File(path);
BufferedImage originalImage = ImageIO.read(file);
@ -268,4 +276,15 @@ public class AppCmmnUtil {
return newImage;
}
public static String bytesToTempFile(String prefix, String ext, byte[] baos) throws FileNotFoundException, IOException {
String tempDir = System.getProperty("java.io.tmpdir");
File tempFile = File.createTempFile(prefix+"_", "."+ext, new File(tempDir));
try (FileOutputStream fos = new FileOutputStream(tempFile)) {
fos.write(baos);
}
return tempFile.getAbsolutePath();
}
}

@ -26,9 +26,11 @@ public abstract class HWPFormat {
protected int currentRunCount;
protected int maxRunCount;
protected List<String> resultFilesPath;
protected List<String> tempFilesPath;
public HWPFormat(Print print, PrintOption printOption, List<DataObject> dataObjectList) {
this.resultFilesPath = new ArrayList<String>();
this.tempFilesPath = new ArrayList<String>();
this.currentRunCount = 0;
this.data = dataObjectList;
this.printOption = printOption;
@ -100,12 +102,20 @@ public abstract class HWPFormat {
new File(resultFilePath).delete();
for(String tempFilePath : tempFilesPath) {
(new File(tempFilePath)).delete();
}
return result;
};
public abstract List<String> getDownloadDataNames();
public String andGetPath(){
for(String tempFilePath : tempFilesPath) {
(new File(tempFilePath)).delete();
}
return resultFilesPath.get(0);
};

Loading…
Cancel
Save