From dd8f40e446f58128dfcfde24539c46b7490ebc39 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 8 Dec 2017 10:50:03 +0300 Subject: web: do not try to get metadata from non-existing images --- .../src/main/java/com/juick/server/util/ImageUtils.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'juick-server-web/src/main/java/com') diff --git a/juick-server-web/src/main/java/com/juick/server/util/ImageUtils.java b/juick-server-web/src/main/java/com/juick/server/util/ImageUtils.java index 4403abc0..94ecf71e 100644 --- a/juick-server-web/src/main/java/com/juick/server/util/ImageUtils.java +++ b/juick-server-web/src/main/java/com/juick/server/util/ImageUtils.java @@ -152,11 +152,17 @@ public class ImageUtils { } public static Integer getImageHeight(File imageFile) throws IOException, ImageReadException { - ImageInfo info = Imaging.getImageInfo(imageFile); - return info.getHeight(); + if (imageFile.exists()) { + ImageInfo info = Imaging.getImageInfo(imageFile); + return info.getHeight(); + } + return 0; } public static Integer getImageWidth(File imageFile) throws IOException, ImageReadException { - ImageInfo info = Imaging.getImageInfo(imageFile); - return info.getWidth(); + if (imageFile.exists()) { + ImageInfo info = Imaging.getImageInfo(imageFile); + return info.getWidth(); + } + return 0; } } \ No newline at end of file -- cgit v1.2.3