From 87d9ea517e2b879da2d271c3d01f5811e49383be Mon Sep 17 00:00:00 2001 From: Jakob Heher Date: Mon, 8 Aug 2022 14:41:53 +0200 Subject: correctly handle jpeg images without EXIF orientation tag --- .../src/main/java/at/asit/pdfover/commons/utils/ImageUtil.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'pdf-over-commons') diff --git a/pdf-over-commons/src/main/java/at/asit/pdfover/commons/utils/ImageUtil.java b/pdf-over-commons/src/main/java/at/asit/pdfover/commons/utils/ImageUtil.java index 4a926226..2b99ea2c 100644 --- a/pdf-over-commons/src/main/java/at/asit/pdfover/commons/utils/ImageUtil.java +++ b/pdf-over-commons/src/main/java/at/asit/pdfover/commons/utils/ImageUtil.java @@ -75,14 +75,16 @@ class EXIFRotation { ExifIFD0Directory metaDir = metadata.getFirstDirectoryOfType(ExifIFD0Directory.class); if (metaDir == null) return NONE; - int orientation = metaDir.getInt(ExifDirectoryBase.TAG_ORIENTATION); + Integer orientation = metaDir.getInteger(ExifDirectoryBase.TAG_ORIENTATION); + if (orientation == null) + return NONE; if (rotationForIndex.length <= orientation) { log.warn("Invalid orientation {} in EXIF metadata for {}", orientation, file.getName()); return NONE; } return rotationForIndex[orientation]; - } catch (ImageProcessingException | MetadataException e) { + } catch (ImageProcessingException e) { log.error("Failed to read EXIF metadata for {}", file.getName(), e); return NONE; } -- cgit v1.2.3