diff --git a/pom.xml b/pom.xml
index f0cfafd..ce70337 100644
--- a/pom.xml
+++ b/pom.xml
@@ -68,19 +68,12 @@
4.5.14
-
org.apache.httpcomponents
httpmime
4.5.14
-
- org.im4java
- im4java
- 1.4.0
-
-
org.apache.commons
commons-lang3
@@ -106,7 +99,7 @@
com.github.pengrad
java-telegram-bot-api
- 6.9.1
+ 7.9.1
@@ -125,7 +118,7 @@
--gc=G1
-H:+ReportExceptionStackTraces
- --initialize-at-build-time=org.apache.commons.logging.LogFactory,org.apache.commons.logging.LogFactoryService
+ --initialize-at-build-time=org.apache.commons.logging.LogFactory,org.apache.commons.logging.LogFactoryService,org.sqlite.util.ProcessRunner
true
diff --git a/src/main/java/com/lion/lionwebsite/Service/GalleryManageService.java b/src/main/java/com/lion/lionwebsite/Service/GalleryManageService.java
index 6477e34..05ccda4 100644
--- a/src/main/java/com/lion/lionwebsite/Service/GalleryManageService.java
+++ b/src/main/java/com/lion/lionwebsite/Service/GalleryManageService.java
@@ -346,7 +346,7 @@ public class GalleryManageService {
return response.toJSONString();
}
- String[] suffixes = {".webp", ".gif"};
+ String[] suffixes = {".avif", ".gif"};
public Callable> getCachedImage(String gid, Integer page, HttpServletRequest request, HttpServletResponse response) {
//检查文件夹是否存在
File folder = new File(cachePath + gid);
diff --git a/src/main/java/com/lion/lionwebsite/Service/QueryService.java b/src/main/java/com/lion/lionwebsite/Service/QueryService.java
index f6b1c81..694b22f 100644
--- a/src/main/java/com/lion/lionwebsite/Service/QueryService.java
+++ b/src/main/java/com/lion/lionwebsite/Service/QueryService.java
@@ -103,7 +103,7 @@ public class QueryService {
String fileName = path.substring(path.lastIndexOf("/") + 1);
String suffix = fileName.substring(fileName.lastIndexOf("."));
fileName = fileName.substring(0, fileName.lastIndexOf("."));
- File image = new File(CachePath, fileName + ".webp");
+ File image = new File(CachePath, fileName + ".avif");
if(image.isFile()){
FileDownload.export(request, response, image.getAbsolutePath());
@@ -111,12 +111,13 @@ public class QueryService {
}
path = "https://ehgt.org/" + path;
- try(ServletOutputStream outputStream = response.getOutputStream()){
+ try(ServletOutputStream outputStream = response.getOutputStream();
+ FileInputStream inputStream = new FileInputStream(image.getAbsoluteFile())){
new URI(path).toURL().openConnection().getInputStream().transferTo(new FileOutputStream(CachePath + fileName + suffix));
GalleryUtil.convertImg(CachePath + fileName + suffix, suffix);
- outputStream.write(new FileInputStream(image.getAbsolutePath()).readAllBytes());
+ outputStream.write(inputStream.readAllBytes());
}catch (IOException | URISyntaxException e){
- e.printStackTrace();
+ System.out.println(e.getMessage());
}
}
}
diff --git a/src/main/java/com/lion/lionwebsite/Util/GalleryUtil.java b/src/main/java/com/lion/lionwebsite/Util/GalleryUtil.java
index 5ddfea3..d3254ca 100644
--- a/src/main/java/com/lion/lionwebsite/Util/GalleryUtil.java
+++ b/src/main/java/com/lion/lionwebsite/Util/GalleryUtil.java
@@ -13,9 +13,6 @@ import org.apache.http.entity.ContentType;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
-import org.im4java.core.ConvertCmd;
-import org.im4java.core.IM4JavaException;
-import org.im4java.core.IMOperation;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
@@ -228,16 +225,13 @@ public class GalleryUtil {
}
public static String convertImg(String imagePath, String suffix){
- ConvertCmd convertCmd = new ConvertCmd(true);
- IMOperation operation = new IMOperation();
- operation.addImage(imagePath);
- operation.format("webp");
- operation.addImage(imagePath.replace(suffix, ".webp"));
+ Runtime rt = Runtime.getRuntime();
try {
- convertCmd.run(operation);
- new File(imagePath).delete();
- return imagePath.replace(suffix, ".webp");
- } catch (IOException | IM4JavaException | InterruptedException e) {
+ Process exec = rt.exec(new String[]{"convert", imagePath, imagePath.replace(suffix, ".avif")});
+ exec.waitFor();
+ boolean ignored = new File(imagePath).delete();
+ return imagePath.replace(suffix, ".avif");
+ } catch (IOException| InterruptedException e) {
System.out.println("文件" + imagePath + "转换失败");
return null;
}