@@ -26,17 +26,11 @@ public class ImageResizeService {
|
||||
@Value("${file.storage.base-path}")
|
||||
private String storagePath;
|
||||
|
||||
/**
|
||||
* Проверяет, является ли файл изображением
|
||||
*/
|
||||
public boolean isImage(String extension) {
|
||||
return extension != null && List.of("jpg", "jpeg", "png", "gif", "webp")
|
||||
.contains(extension.toLowerCase());
|
||||
}
|
||||
|
||||
/**
|
||||
* Генерирует два размера для изображения
|
||||
*/
|
||||
@Transactional
|
||||
public void generateSizes(FileEntity file, byte[] data) throws IOException {
|
||||
if (!isImage(file.getFileExtension())) {
|
||||
@@ -65,9 +59,6 @@ public class ImageResizeService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ресайзит и сохраняет
|
||||
*/
|
||||
private String resizeAndSave(BufferedImage original, String fileName, int targetWidth) throws IOException {
|
||||
int targetHeight = (int) ((double) original.getHeight() / original.getWidth() * targetWidth);
|
||||
|
||||
@@ -86,9 +77,6 @@ public class ImageResizeService {
|
||||
return filePath.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Получить путь к нужному размеру
|
||||
*/
|
||||
public String getPath(FileEntity file, String size) {
|
||||
|
||||
if ("thumbnail".equals(size) && file.getThumbnailPath() != null) {
|
||||
|
||||
Reference in New Issue
Block a user