From 10ee29dcb05f992fe2b7aa726b6ac7c9e9aba87d Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Mon, 23 Jul 2018 15:47:54 +0300 Subject: Add TwelveMonkeys jpeg library to handle JPG CMYK and other exotic jpegs --- .../src/main/java/com/juick/server/util/ImageUtils.java | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'juick-common/src/main') diff --git a/juick-common/src/main/java/com/juick/server/util/ImageUtils.java b/juick-common/src/main/java/com/juick/server/util/ImageUtils.java index cea4cc88..d6a455a4 100644 --- a/juick-common/src/main/java/com/juick/server/util/ImageUtils.java +++ b/juick-common/src/main/java/com/juick/server/util/ImageUtils.java @@ -156,19 +156,14 @@ public class ImageUtils { Iterator iter = ImageIO.getImageReadersBySuffix(suffix); while(iter.hasNext()) { ImageReader reader = iter.next(); - ImageInputStream stream = null; - try { - stream = new FileImageInputStream(imgFile); + try (ImageInputStream stream = ImageIO.createImageInputStream(imgFile)) { reader.setInput(stream); attachment.setWidth(reader.getWidth(reader.getMinIndex())); attachment.setHeight(reader.getHeight(reader.getMinIndex())); return attachment; - } catch (IOException e) { - logger.warn("Error reading: " + imgFile.getAbsolutePath(), e); + } catch (Exception e) { + logger.debug("Error reading {}, trying next reader", imgFile.getAbsolutePath()); } finally { - if (stream != null) { - stream.close(); - } reader.dispose(); } } -- cgit v1.2.3