do not try to create a thumbnail if the image doesn't exist
This commit is contained in:
@@ -152,7 +152,7 @@ public class ScatterPlot implements ConcretePlotter {
|
|||||||
final int thumbnailMaxHeight) {
|
final int thumbnailMaxHeight) {
|
||||||
|
|
||||||
Path result;
|
Path result;
|
||||||
if (thumbnailMaxWidth > 0 && thumbnailMaxHeight > 0) {
|
if (thumbnailMaxWidth > 0 && thumbnailMaxHeight > 0 && Files.exists(originalImage)) {
|
||||||
try {
|
try {
|
||||||
final long start = System.nanoTime();
|
final long start = System.nanoTime();
|
||||||
final BufferedImage image = ImageIO.read(originalImage.toFile());
|
final BufferedImage image = ImageIO.read(originalImage.toFile());
|
||||||
@@ -164,7 +164,7 @@ public class ScatterPlot implements ConcretePlotter {
|
|||||||
ImageIO.write(thumbnail, "JPG", thumbnailPath.toFile());
|
ImageIO.write(thumbnail, "JPG", thumbnailPath.toFile());
|
||||||
LOGGER.info("thumbnail creation: " + (System.nanoTime() - start) / 1_000_000.0 + "ms");
|
LOGGER.info("thumbnail creation: " + (System.nanoTime() - start) / 1_000_000.0 + "ms");
|
||||||
result = thumbnailPath;
|
result = thumbnailPath;
|
||||||
} catch (final IOException e) {
|
} catch (final IOException | RuntimeException e) {
|
||||||
LOGGER.warn("failed to scale image", e);
|
LOGGER.warn("failed to scale image", e);
|
||||||
result = null;
|
result = null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user