From b1621bbb9d278d8a5c4631b5804bf6a61678ef41 Mon Sep 17 00:00:00 2001 From: tknall Date: Tue, 11 Jan 2011 10:18:13 +0000 Subject: Bugfix: TIFF based QR-Codes resulted in NPE. git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@720 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- .../pdfas/placeholder/SignaturePlaceholderExtractor.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main/java/at/gv/egiz/pdfas/placeholder/SignaturePlaceholderExtractor.java b/src/main/java/at/gv/egiz/pdfas/placeholder/SignaturePlaceholderExtractor.java index 85d14f8..c9d5cd7 100644 --- a/src/main/java/at/gv/egiz/pdfas/placeholder/SignaturePlaceholderExtractor.java +++ b/src/main/java/at/gv/egiz/pdfas/placeholder/SignaturePlaceholderExtractor.java @@ -236,8 +236,20 @@ public class SignaturePlaceholderExtractor extends PDFStreamEngine { */ private SignaturePlaceholderData checkImage(PDXObjectImage image) throws IOException { BufferedImage bimg = image.getRGBImage(); - if(bimg.getHeight() < 10 || bimg.getWidth() < 10) + if (bimg == null) { + String type = image.getSuffix(); + if (type != null) { + type = type.toUpperCase() + " images"; + } else { + type = "Image type"; + } + log.info("Unable to extract image for QRCode analysis. " + type + " not supported. Add additional JAI Image filters to your classpath. Refer to https://jai.dev.java.net. Skipping image."); + return null; + } + if(bimg.getHeight() < 10 || bimg.getWidth() < 10) { + log.debug("Image too small for QRCode. Skipping image."); return null; + } LuminanceSource source = new BufferedImageLuminanceSource(bimg); BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source)); -- cgit v1.2.3