From 91392e2b742b7da5826c13797e610cf0acc36753 Mon Sep 17 00:00:00 2001 From: Hashir Rajah Date: Tue, 24 Sep 2024 15:02:33 +0400 Subject: [PATCH 01/10] Add jackson --- plugin.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugin.xml b/plugin.xml index f2f8368..98a16bb 100755 --- a/plugin.xml +++ b/plugin.xml @@ -12,6 +12,9 @@ + + + From ab0681535a2cca47761e4ce67c2d199ee32223c7 Mon Sep 17 00:00:00 2001 From: Hashir Rajah Date: Tue, 24 Sep 2024 15:02:42 +0400 Subject: [PATCH 02/10] Import jackson --- src/android/Thumbnails.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/android/Thumbnails.java b/src/android/Thumbnails.java index 4ba04a1..8532255 100755 --- a/src/android/Thumbnails.java +++ b/src/android/Thumbnails.java @@ -16,10 +16,12 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.ObjectWriter; public class Thumbnails { - public static void thumbnail(Options thumbnailOptions) throws IOException { + public static void thumbnail(Options thumbnailOptions) throws Exception { long begin = System.currentTimeMillis(); Bitmap bitmap = thumbnailSmallImage(thumbnailOptions); @@ -37,7 +39,7 @@ public static void thumbnail(Options thumbnailOptions) throws IOException { bitmap = null; } - private static Bitmap thumbnailSmallImage(Options thumbnailOptions) throws IOException { + private static Bitmap thumbnailSmallImage(Options thumbnailOptions) throws Exception { BitmapFactory.Options options = calculateImageSize(thumbnailOptions.sourcePath); options.inJustDecodeBounds = false; From 6b2eedf0fcb9e36f10b7dd4a0108a34ba99f85a2 Mon Sep 17 00:00:00 2001 From: Hashir Rajah Date: Tue, 24 Sep 2024 15:04:42 +0400 Subject: [PATCH 03/10] 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(); From 5cb44dc97c3443b34b4a90e50396f08301e8b903 Mon Sep 17 00:00:00 2001 From: Hashir Rajah Date: Tue, 24 Sep 2024 16:10:19 +0400 Subject: [PATCH 04/10] Latest jackson version --- plugin.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin.xml b/plugin.xml index 98a16bb..1134055 100755 --- a/plugin.xml +++ b/plugin.xml @@ -12,8 +12,8 @@ - - + + From 060c2c42aeb30aa3aa86672db5060b5e7937ce82 Mon Sep 17 00:00:00 2001 From: Hashir Rajah Date: Tue, 24 Sep 2024 16:19:11 +0400 Subject: [PATCH 05/10] Remove jackson for test --- plugin.xml | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugin.xml b/plugin.xml index 1134055..f637e5c 100755 --- a/plugin.xml +++ b/plugin.xml @@ -12,8 +12,6 @@ - - From 2d458ee3dea9af2997533aab30e96d5e7683d6c1 Mon Sep 17 00:00:00 2001 From: Hashir Rajah Date: Tue, 24 Sep 2024 16:24:38 +0400 Subject: [PATCH 06/10] Add jackson --- plugin.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugin.xml b/plugin.xml index f637e5c..cb9dff2 100755 --- a/plugin.xml +++ b/plugin.xml @@ -12,6 +12,8 @@ + + From 49d5d38d8e6eb73feaa89ee4de2cc9298c8a2ef6 Mon Sep 17 00:00:00 2001 From: Hashir Rajah Date: Wed, 25 Sep 2024 11:41:26 +0400 Subject: [PATCH 07/10] Remove else --- src/android/ThumbnailsCordovaPlugin.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/android/ThumbnailsCordovaPlugin.java b/src/android/ThumbnailsCordovaPlugin.java index b848a0c..6bc0d2c 100755 --- a/src/android/ThumbnailsCordovaPlugin.java +++ b/src/android/ThumbnailsCordovaPlugin.java @@ -64,7 +64,8 @@ public void run() { if(!sourceFile.exists()){ callbackContext.error("The image file does not exist at path: " + options.sourcePath ); throw new IOException(String.format("The image file does not exist")); - } else if(!targetFile.exists()) { + } + if(!targetFile.exists()) { targetFile.getParentFile().mkdirs(); targetFile.createNewFile(); } From f0fa9943f0f6a7d55f8e082ad2e6bd6925588de8 Mon Sep 17 00:00:00 2001 From: Hashir Rajah Date: Thu, 26 Sep 2024 16:07:08 +0400 Subject: [PATCH 08/10] Var name --- src/android/Thumbnails.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/android/Thumbnails.java b/src/android/Thumbnails.java index 503bb06..29270f5 100755 --- a/src/android/Thumbnails.java +++ b/src/android/Thumbnails.java @@ -46,8 +46,8 @@ private static Bitmap thumbnailSmallImage(Options thumbnailOptions) throws Excep Bitmap bitmap = BitmapFactory.decodeFile(thumbnailOptions.sourcePath, options); if (bitmap == null) { - ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter(); - String optionsJSON = ow.writeValueAsString(options); + ObjectWriter objectWriter = new ObjectMapper().writer().withDefaultPrettyPrinter(); + String optionsJSON = objectWriter.writeValueAsString(options); throw new Exception("Could not decode file into bitmap object { sourcePath: " + thumbnailOptions.sourcePath + " options: " + optionsJSON + " }"); } From 604331ed94eccd1d9fdb7aa9641dfb9068f118b9 Mon Sep 17 00:00:00 2001 From: Hashir Rajah Date: Tue, 1 Oct 2024 12:20:10 +0400 Subject: [PATCH 09/10] New package version --- package-lock.json | 4 ++-- package.json | 2 +- plugin.xml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 62eb6f6..0f4cee2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@spoonconsulting/cordova-plugin-thumbnail", - "version": "1.0.3", + "version": "1.0.4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@spoonconsulting/cordova-plugin-thumbnail", - "version": "1.0.3", + "version": "1.0.4", "license": "Apache 2.0", "engines": { "cordovaDependencies": { diff --git a/package.json b/package.json index 2d5b9cd..7a531bf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@spoonconsulting/cordova-plugin-thumbnail", - "version": "1.0.3", + "version": "1.0.4", "description": "Image thumbnail generator for Cordova project", "cordova": { "id": "@spoonconsulting/cordova-plugin-thumbnail", diff --git a/plugin.xml b/plugin.xml index cb9dff2..6bee36e 100755 --- a/plugin.xml +++ b/plugin.xml @@ -1,5 +1,5 @@ - + Thumbnail Cordova Thumbnail Plugin Apache 2.0 From a661474b92329bd9000efb5dd68fd4dd1d2c71f8 Mon Sep 17 00:00:00 2001 From: Hashir Rajah Date: Tue, 1 Oct 2024 12:20:20 +0400 Subject: [PATCH 10/10] Add changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..1c9b701 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,2 @@ +## [1.0.4](https://github.com/spoonconsulting/cordova-plugin-thumbnail/compare/1.0.3...1.0.4) (2024-10-01) +* **Android:** Return more informative error if BitmapFactory.decodeFile() returns null