Update ConvertImgPDFController.java

This commit is contained in:
Ludy87 2025-07-19 01:44:14 +02:00
parent e874450049
commit 4f65bb1d0c
No known key found for this signature in database
GPG Key ID: 92696155E0220F94

View File

@ -117,10 +117,11 @@ public class ConvertImgPDFController {
}
String pythonVersion = CheckProgramInstall.getAvailablePythonCommand();
Path pngToWebpScript = GeneralUtils.extractScript("png_to_webp.py");
List<String> command = new ArrayList<>();
command.add(pythonVersion);
command.add("./scripts/png_to_webp.py"); // Python script to handle the conversion
command.add(pngToWebpScript.toAbsolutePath().toString()); // Python script to handle the conversion
// Create a temporary directory for the output WebP files
tempOutputDir = Files.createTempDirectory("webp_output");
@ -232,7 +233,8 @@ public class ConvertImgPDFController {
PdfUtils.imageToPdf(file, fitOption, autoRotate, colorType, pdfDocumentFactory);
return WebResponseUtils.bytesToWebResponse(
bytes,
new File(file[0].getOriginalFilename()).getName().replaceFirst("[.][^.]+$", "") + "_converted.pdf");
new File(file[0].getOriginalFilename()).getName().replaceFirst("[.][^.]+$", "")
+ "_converted.pdf");
}
private String getMediaType(String imageFormat) {