From 6b2eedf0fcb9e36f10b7dd4a0108a34ba99f85a2 Mon Sep 17 00:00:00 2001 From: Hashir Rajah Date: Tue, 24 Sep 2024 15:04:42 +0400 Subject: [PATCH] Add null check --- src/android/Thumbnails.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/android/Thumbnails.java b/src/android/Thumbnails.java index 8532255..503bb06 100755 --- a/src/android/Thumbnails.java +++ b/src/android/Thumbnails.java @@ -45,6 +45,12 @@ private static Bitmap thumbnailSmallImage(Options thumbnailOptions) throws Excep options.inJustDecodeBounds = false; Bitmap bitmap = BitmapFactory.decodeFile(thumbnailOptions.sourcePath, options); + if (bitmap == null) { + ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter(); + String optionsJSON = ow.writeValueAsString(options); + throw new Exception("Could not decode file into bitmap object { sourcePath: " + thumbnailOptions.sourcePath + " options: " + optionsJSON + " }"); + } + long begin = System.currentTimeMillis(); int oWidth = bitmap.getWidth(); int oHeight = bitmap.getHeight();