mirror of https://github.com/halo-dev/halo
commit
9a7608831e
|
@ -56,6 +56,7 @@ ext {
|
||||||
jgitVersion = '5.3.0.201903130848-r'
|
jgitVersion = '5.3.0.201903130848-r'
|
||||||
flexmarkVersion = '0.42.12'
|
flexmarkVersion = '0.42.12'
|
||||||
thumbnailatorVersion = '0.4.8'
|
thumbnailatorVersion = '0.4.8'
|
||||||
|
image4jVersion = '0.7zensight1'
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
@ -96,6 +97,7 @@ dependencies {
|
||||||
implementation "com.vladsch.flexmark:flexmark-html-parser:$flexmarkVersion"
|
implementation "com.vladsch.flexmark:flexmark-html-parser:$flexmarkVersion"
|
||||||
|
|
||||||
implementation "net.coobird:thumbnailator:$thumbnailatorVersion"
|
implementation "net.coobird:thumbnailator:$thumbnailatorVersion"
|
||||||
|
implementation "net.sf.image4j:image4j:$image4jVersion"
|
||||||
|
|
||||||
runtimeOnly 'com.h2database:h2'
|
runtimeOnly 'com.h2database:h2'
|
||||||
runtimeOnly 'mysql:mysql-connector-java'
|
runtimeOnly 'mysql:mysql-connector-java'
|
||||||
|
|
|
@ -17,13 +17,16 @@ import run.halo.app.utils.HaloUtils;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
import net.sf.image4j.codec.ico.ICODecoder;
|
||||||
|
|
||||||
import static run.halo.app.model.support.HaloConst.FILE_SEPARATOR;
|
import static run.halo.app.model.support.HaloConst.FILE_SEPARATOR;
|
||||||
|
|
||||||
|
@ -151,7 +154,7 @@ public class LocalFileHandler implements FileHandler {
|
||||||
Path thumbnailPath = Paths.get(workDir + thumbnailSubFilePath);
|
Path thumbnailPath = Paths.get(workDir + thumbnailSubFilePath);
|
||||||
|
|
||||||
// Read as image
|
// Read as image
|
||||||
BufferedImage originalImage = ImageIO.read(uploadPath.toFile());
|
BufferedImage originalImage = getImageFromFile(uploadPath.toFile(), extension);
|
||||||
// Set width and height
|
// Set width and height
|
||||||
uploadResult.setWidth(originalImage.getWidth());
|
uploadResult.setWidth(originalImage.getWidth());
|
||||||
uploadResult.setHeight(originalImage.getHeight());
|
uploadResult.setHeight(originalImage.getHeight());
|
||||||
|
@ -239,4 +242,14 @@ public class LocalFileHandler implements FileHandler {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private BufferedImage getImageFromFile(File file, String extension) throws IOException {
|
||||||
|
log.debug("Current File type is : [{}]", extension);
|
||||||
|
|
||||||
|
if ("ico".equals(extension)) {
|
||||||
|
return ICODecoder.read(file).get(0);
|
||||||
|
} else {
|
||||||
|
return ImageIO.read(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue