diff --git a/htroot/api/snapshot.java b/htroot/api/snapshot.java index b734d65b4..db60af1b7 100644 --- a/htroot/api/snapshot.java +++ b/htroot/api/snapshot.java @@ -304,6 +304,10 @@ public class snapshot { Image image; try { image = ImageParser.parse(imageFile.getAbsolutePath(), FileUtils.read(imageFile)); + if(image == null) { + /* Should not happen. If so, ImageParser.parse() should already have logged about the error */ + return null; + } final Image scaled = image.getScaledInstance(width, height, Image.SCALE_AREA_AVERAGING); final MediaTracker mediaTracker = new MediaTracker(new Container()); mediaTracker.addImage(scaled, 0); diff --git a/source/net/yacy/cora/util/Html2Image.java b/source/net/yacy/cora/util/Html2Image.java index 217817744..80ece6cab 100644 --- a/source/net/yacy/cora/util/Html2Image.java +++ b/source/net/yacy/cora/util/Html2Image.java @@ -199,7 +199,11 @@ public class Html2Image { try { File newPngFile = new File(pngFile.getAbsolutePath() + ".png"); pngFile.renameTo(newPngFile); - Image img = ImageParser.parse(pngFile.getAbsolutePath(), FileUtils.read(newPngFile)); + final Image img = ImageParser.parse(pngFile.getAbsolutePath(), FileUtils.read(newPngFile)); + if(img == null) { + /* Should not happen. If so, ImageParser.parse() should already have logged about the error */ + return false; + } final Image scaled = img.getScaledInstance(width, height, Image.SCALE_AREA_AVERAGING); final MediaTracker mediaTracker = new MediaTracker(new Container()); mediaTracker.addImage(scaled, 0);