aboutsummaryrefslogtreecommitdiff
path: root/juick-common/src/main/java/com/juick/server/util
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-07-23 15:47:54 +0300
committerGravatar Vitaly Takmazov2018-07-23 15:48:12 +0300
commit10ee29dcb05f992fe2b7aa726b6ac7c9e9aba87d (patch)
treeccb9e152d63b5891019ff7fffe4bf150ae52b5b6 /juick-common/src/main/java/com/juick/server/util
parentf6e91616f77fe2426fcdc92e4cdfd3a847f8ac30 (diff)
Add TwelveMonkeys jpeg library to handle JPG CMYK and other exotic jpegs
Diffstat (limited to 'juick-common/src/main/java/com/juick/server/util')
-rw-r--r--juick-common/src/main/java/com/juick/server/util/ImageUtils.java11
1 files changed, 3 insertions, 8 deletions
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<ImageReader> 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();
}
}