dev add check similar
Test Workflow / test (push) Has been cancelled

This commit is contained in:
2026-04-29 18:14:15 +07:00
parent 9686eb453f
commit 18383b1b62
2 changed files with 18 additions and 1 deletions
+1
View File
@@ -63,6 +63,7 @@ dependencies {
implementation group: 'com.squareup.okhttp3', name: 'okhttp', version: '4.12.0' implementation group: 'com.squareup.okhttp3', name: 'okhttp', version: '4.12.0'
implementation 'com.maxmind.geoip2:geoip2:4.2.0' implementation 'com.maxmind.geoip2:geoip2:4.2.0'
implementation 'org.sejda.imageio:webp-imageio:0.1.6'
implementation project(':referral') implementation project(':referral')
@@ -25,6 +25,8 @@ import ru.soune.nocopy.service.search.SearchImageService;
import ru.soune.nocopy.service.tariff.TariffConstants; import ru.soune.nocopy.service.tariff.TariffConstants;
import ru.soune.nocopy.service.tariff.TariffInfoService; import ru.soune.nocopy.service.tariff.TariffInfoService;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
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;
@@ -150,7 +152,7 @@ public class ImageFoundRequestHandler implements RequestHandler {
String url = image.getUrl(); String url = image.getUrl();
Path tempFile = null; Path tempFile = null;
try { try {
tempFile = fileUploadService.downloadImageFromUrl(url); tempFile = convertToSupportedFormat(fileUploadService.downloadImageFromUrl(url));
String filePath = tempFile.toAbsolutePath().toString(); String filePath = tempFile.toAbsolutePath().toString();
@@ -191,4 +193,18 @@ public class ImageFoundRequestHandler implements RequestHandler {
return new BaseResponse(request.getMsgId(), MessageCode.SUCCESS.getCode(), return new BaseResponse(request.getMsgId(), MessageCode.SUCCESS.getCode(),
message, finalResponse); message, finalResponse);
} }
public Path convertToSupportedFormat(Path imagePath) throws IOException {
String fileName = imagePath.getFileName().toString().toLowerCase();
if (fileName.matches(".*\\.(jpg|jpeg|png|bmp)$")) {
return imagePath;
}
BufferedImage image = ImageIO.read(imagePath.toFile());
Path pngFile = Files.createTempFile("converted_", ".png");
ImageIO.write(image, "PNG", pngFile.toFile());
return pngFile;
}
} }