import lombok.extern.slf4j.Slf4j;
import net.coobird.thumbnailator.Thumbnails;
import java.io.IOException;
import java.io.InputStream;
/**
* @author zj
* @since 1.0
**/
@Slf4j
public class ThumbnailsUtils {
public static void thumbnails(String sourceFilePath, String thumbnailsPath) {
try {
Thumbnails.of(sourceFilePath)
.scale(0.3f)
.outputQuality(0.3f)
.toFile(thumbnailsPath);
} catch (IOException e) {
log.error("生成縮略圖失敗", e);
}
}
public static void thumbnails(InputStream sourceFileInputStream, String thumbnailsPath) {
try {
Thumbnails.of(sourceFileInputStream)
.scale(0.3f)
.outputQuality(0.3f)
.toFile(thumbnailsPath);
} catch (IOException e) {
log.error("生成縮略圖失敗", e);
}
}
}