From 31e222c9c1256ba59a17edb48c566f1536886079 Mon Sep 17 00:00:00 2001 From: parveshneedhoo Date: Tue, 24 Oct 2023 13:14:39 +0400 Subject: [PATCH 01/12] save height and width for ios on picker --- src/ios/SOSPicker.m | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/ios/SOSPicker.m b/src/ios/SOSPicker.m index fc4bcbf5..5e1bccbb 100644 --- a/src/ios/SOSPicker.m +++ b/src/ios/SOSPicker.m @@ -187,6 +187,8 @@ - (void)assetsPickerController:(GMImagePickerController *)picker didFinishPickin NSFileManager* fileMgr = [[NSFileManager alloc] init]; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES); NSString *libPath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"NoCloud"]; + NSMutableArray * imageSize = [[NSMutableArray alloc] init]; + NSMutableArray * result_with_image_size = [[NSMutableArray alloc] init]; NSError* err = nil; NSString* filePath; @@ -201,7 +203,13 @@ - (void)assetsPickerController:(GMImagePickerController *)picker didFinishPickin do { filePath = [NSString stringWithFormat:@"%@/%@.%@", libPath, [[NSUUID UUID] UUIDString], @"jpg"]; } while ([fileMgr fileExistsAtPath:filePath]); - + + UIImage *image = [UIImage imageNamed:item.image_fullsize]; + NSNumber *imageWidth = [NSNumber numberWithFloat:image.size.width]; + NSNumber *imageHeight = [NSNumber numberWithFloat:image.size.height]; + NSDictionary *imageSizeDict = @{@"width": imageWidth, @"height": imageHeight}; + [imageSize addObject: imageSizeDict]; + NSData* data = nil; if (self.width == 0 && self.height == 0) { // no scaling required @@ -245,7 +253,11 @@ - (void)assetsPickerController:(GMImagePickerController *)picker didFinishPickin } if (result == nil) { - result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:result_all]; + for(int i = 0; i Date: Tue, 24 Oct 2023 15:19:07 +0400 Subject: [PATCH 02/12] save image width and height for android --- src/android/ImagePicker.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/android/ImagePicker.java b/src/android/ImagePicker.java index 3149e678..22091d43 100644 --- a/src/android/ImagePicker.java +++ b/src/android/ImagePicker.java @@ -8,6 +8,7 @@ import android.content.Intent; import android.content.pm.PackageManager; import android.database.Cursor; +import android.graphics.BitmapFactory; import android.graphics.Color; import android.net.Uri; import android.os.Build; @@ -76,6 +77,7 @@ public boolean execute(String action, final JSONArray args, final CallbackContex public void onActivityResult(int requestCode, int resultCode, Intent data) { ExecutorService executor = Executors.newSingleThreadExecutor(); + ArrayList imageInfos = new ArrayList<>(); executor.execute(() -> { try { cordova.getActivity().runOnUiThread(() -> { @@ -111,7 +113,17 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) { } } } - JSONArray res = new JSONArray(fileURIs); + for (int i=0; i Date: Tue, 24 Oct 2023 17:12:49 +0400 Subject: [PATCH 03/12] correct empty jsonobject --- src/android/ImagePicker.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/android/ImagePicker.java b/src/android/ImagePicker.java index 22091d43..46fb4d9f 100644 --- a/src/android/ImagePicker.java +++ b/src/android/ImagePicker.java @@ -121,6 +121,9 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) { int imageHeight = options.outHeight; int imageWidth = options.outWidth; JSONObject json = new JSONObject(); + json.put("path", fileURIs.get(i)); + json.put("width", imageWidth); + json.put("height", imageHeight); imageInfos.add(json); } JSONArray res = new JSONArray(imageInfos); From 4cbd6f9f78f4d6e938c6dca943fab55f293f3fc0 Mon Sep 17 00:00:00 2001 From: parveshneedhoo Date: Fri, 27 Oct 2023 17:30:32 +0400 Subject: [PATCH 04/12] refactor --- src/android/ImagePicker.java | 2 +- src/ios/SOSPicker.m | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/android/ImagePicker.java b/src/android/ImagePicker.java index 46fb4d9f..9a79c7de 100644 --- a/src/android/ImagePicker.java +++ b/src/android/ImagePicker.java @@ -113,7 +113,7 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) { } } } - for (int i=0; i Date: Tue, 31 Oct 2023 18:20:05 +0400 Subject: [PATCH 05/12] refactor put height and width directly in object --- src/android/ImagePicker.java | 6 ++---- src/ios/SOSPicker.m | 30 ++++++++++++------------------ 2 files changed, 14 insertions(+), 22 deletions(-) diff --git a/src/android/ImagePicker.java b/src/android/ImagePicker.java index 9a79c7de..68d9ecae 100644 --- a/src/android/ImagePicker.java +++ b/src/android/ImagePicker.java @@ -118,12 +118,10 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) { options.inJustDecodeBounds = true; Uri ImageUri = Uri.parse(fileURIs.get(i)); BitmapFactory.decodeFile(new File(ImageUri.getPath()).getAbsolutePath(), options); - int imageHeight = options.outHeight; - int imageWidth = options.outWidth; JSONObject json = new JSONObject(); json.put("path", fileURIs.get(i)); - json.put("width", imageWidth); - json.put("height", imageHeight); + json.put("width", options.outWidth); + json.put("height", options.outHeight); imageInfos.add(json); } JSONArray res = new JSONArray(imageInfos); diff --git a/src/ios/SOSPicker.m b/src/ios/SOSPicker.m index 8941a430..752a061f 100644 --- a/src/ios/SOSPicker.m +++ b/src/ios/SOSPicker.m @@ -187,8 +187,6 @@ - (void)assetsPickerController:(GMImagePickerController *)picker didFinishPickin NSFileManager* fileMgr = [[NSFileManager alloc] init]; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES); NSString *libPath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"NoCloud"]; - NSMutableArray *imageSize = [[NSMutableArray alloc] init]; - NSMutableArray *result_with_image_size = [[NSMutableArray alloc] init]; NSError* err = nil; NSString* filePath; @@ -204,22 +202,19 @@ - (void)assetsPickerController:(GMImagePickerController *)picker didFinishPickin filePath = [NSString stringWithFormat:@"%@/%@.%@", libPath, [[NSUUID UUID] UUIDString], @"jpg"]; } while ([fileMgr fileExistsAtPath:filePath]); - UIImage *image = [UIImage imageNamed:item.image_fullsize]; - NSNumber *imageWidth = [NSNumber numberWithFloat:image.size.width]; - NSNumber *imageHeight = [NSNumber numberWithFloat:image.size.height]; - NSDictionary *imageSizeDict = @{@"width": imageWidth, @"height": imageHeight}; - [imageSize addObject: imageSizeDict]; - NSData* data = nil; if (self.width == 0 && self.height == 0) { // no scaling required if (self.outputType == BASE64_STRING){ UIImage* image = [UIImage imageNamed:item.image_fullsize]; - [resultList addObject:[UIImageJPEGRepresentation(image, self.quality/100.0f) base64EncodedStringWithOptions:0]]; + NSDictionary *imageInfo = @{@"path":[UIImageJPEGRepresentation(image, self.quality/100.0f) base64EncodedStringWithOptions:0], @"width": [NSNumber numberWithFloat:image.size.width], @"height": [NSNumber numberWithFloat:image.size.height]}; + [resultList addObject: imageInfo]; } else { if (self.quality == 100) { // no scaling, no downsampling, this is the fastest option - [resultList addObject:item.image_fullsize]; + UIImage* image = [UIImage imageNamed:item.image_fullsize]; + NSDictionary *imageInfo = @{@"path":item.image_fullsize, @"width": [NSNumber numberWithFloat:image.size.width], @"height": [NSNumber numberWithFloat:image.size.height]}; + [resultList addObject: imageInfo]; } else { // resample first @@ -229,7 +224,8 @@ - (void)assetsPickerController:(GMImagePickerController *)picker didFinishPickin result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsString:[err localizedDescription]]; break; } else { - [resultList addObject:[[NSURL fileURLWithPath:filePath] absoluteString]]; + NSDictionary *imageInfo = @{@"path":[[NSURL fileURLWithPath:filePath] absoluteString], @"width": [NSNumber numberWithFloat:image.size.width], @"height": [NSNumber numberWithFloat:image.size.height]}; + [resultList addObject: imageInfo]; } } } @@ -244,20 +240,18 @@ - (void)assetsPickerController:(GMImagePickerController *)picker didFinishPickin break; } else { if(self.outputType == BASE64_STRING){ - [resultList addObject:[data base64EncodedStringWithOptions:0]]; + NSDictionary *imageInfo = @{@"path":[data base64EncodedStringWithOptions:0], @"width": [NSNumber numberWithFloat:scaledImage.size.width], @"height": [NSNumber numberWithFloat:scaledImage.size.height]}; + [resultList addObject: imageInfo]; } else { - [resultList addObject:[[NSURL fileURLWithPath:filePath] absoluteString]]; + NSDictionary *imageInfo = @{@"path":[[NSURL fileURLWithPath:filePath] absoluteString], @"width": [NSNumber numberWithFloat:scaledImage.size.width], @"height": [NSNumber numberWithFloat:scaledImage.size.height]}; + [resultList addObject: imageInfo]; } } } } if (result == nil) { - for(int i = 0; i < resultList.count; i++) { - NSDictionary *imageInfo = @{@"path": resultList[i], @"width": imageSize[i][@"width"], @"height": imageSize[i][@"height"]}; - [result_with_image_size addObject:imageInfo]; - } - result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:result_with_image_size]; + result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:resultList]; } [self.viewController dismissViewControllerAnimated:YES completion:nil]; From ed1adbdce8973af8cc295bc99695db7e1d5e6c4e Mon Sep 17 00:00:00 2001 From: parveshneedhoo Date: Thu, 9 Nov 2023 11:09:10 +0400 Subject: [PATCH 06/12] separate variables on different lines --- src/ios/SOSPicker.m | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/ios/SOSPicker.m b/src/ios/SOSPicker.m index 752a061f..cbbe5d02 100644 --- a/src/ios/SOSPicker.m +++ b/src/ios/SOSPicker.m @@ -207,13 +207,17 @@ - (void)assetsPickerController:(GMImagePickerController *)picker didFinishPickin // no scaling required if (self.outputType == BASE64_STRING){ UIImage* image = [UIImage imageNamed:item.image_fullsize]; - NSDictionary *imageInfo = @{@"path":[UIImageJPEGRepresentation(image, self.quality/100.0f) base64EncodedStringWithOptions:0], @"width": [NSNumber numberWithFloat:image.size.width], @"height": [NSNumber numberWithFloat:image.size.height]}; + NSDictionary *imageInfo = @{@"path":[UIImageJPEGRepresentation(image, self.quality/100.0f) base64EncodedStringWithOptions:0], + @"width": [NSNumber numberWithFloat:image.size.width], + @"height": [NSNumber numberWithFloat:image.size.height]}; [resultList addObject: imageInfo]; } else { if (self.quality == 100) { // no scaling, no downsampling, this is the fastest option UIImage* image = [UIImage imageNamed:item.image_fullsize]; - NSDictionary *imageInfo = @{@"path":item.image_fullsize, @"width": [NSNumber numberWithFloat:image.size.width], @"height": [NSNumber numberWithFloat:image.size.height]}; + NSDictionary *imageInfo = @{@"path":item.image_fullsize, + @"width": [NSNumber numberWithFloat:image.size.width], + @"height": [NSNumber numberWithFloat:image.size.height]}; [resultList addObject: imageInfo]; } else { @@ -224,7 +228,9 @@ - (void)assetsPickerController:(GMImagePickerController *)picker didFinishPickin result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsString:[err localizedDescription]]; break; } else { - NSDictionary *imageInfo = @{@"path":[[NSURL fileURLWithPath:filePath] absoluteString], @"width": [NSNumber numberWithFloat:image.size.width], @"height": [NSNumber numberWithFloat:image.size.height]}; + NSDictionary *imageInfo = @{@"path":[[NSURL fileURLWithPath:filePath] absoluteString], + @"width": [NSNumber numberWithFloat:image.size.width], + @"height": [NSNumber numberWithFloat:image.size.height]}; [resultList addObject: imageInfo]; } } @@ -240,10 +246,14 @@ - (void)assetsPickerController:(GMImagePickerController *)picker didFinishPickin break; } else { if(self.outputType == BASE64_STRING){ - NSDictionary *imageInfo = @{@"path":[data base64EncodedStringWithOptions:0], @"width": [NSNumber numberWithFloat:scaledImage.size.width], @"height": [NSNumber numberWithFloat:scaledImage.size.height]}; + NSDictionary *imageInfo = @{@"path":[data base64EncodedStringWithOptions:0], + @"width": [NSNumber numberWithFloat:scaledImage.size.width], + @"height": [NSNumber numberWithFloat:scaledImage.size.height]}; [resultList addObject: imageInfo]; } else { - NSDictionary *imageInfo = @{@"path":[[NSURL fileURLWithPath:filePath] absoluteString], @"width": [NSNumber numberWithFloat:scaledImage.size.width], @"height": [NSNumber numberWithFloat:scaledImage.size.height]}; + NSDictionary *imageInfo = @{@"path":[[NSURL fileURLWithPath:filePath] absoluteString], + @"width": [NSNumber numberWithFloat:scaledImage.size.width], + @"height": [NSNumber numberWithFloat:scaledImage.size.height]}; [resultList addObject: imageInfo]; } } From 7e80439c96a1401b9cafcf2e8c2bf81647e0a666 Mon Sep 17 00:00:00 2001 From: parveshneedhoo Date: Fri, 10 Nov 2023 12:01:23 +0400 Subject: [PATCH 07/12] Bump version to 2.0.5 --- CHANGELOD.md | 5 +++++ package-lock.json | 4 ++-- package.json | 2 +- plugin.xml | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOD.md b/CHANGELOD.md index 9f1c6f8c..2f931905 100644 --- a/CHANGELOD.md +++ b/CHANGELOD.md @@ -1,3 +1,8 @@ +## [2.0.5](https://github.com/spoonconsulting/cordova-plugin-telerik-imagepicker/compare/2.0.4...2.0.5) (2023-11-10) + +* **android:** Return the Height and Width of selected images along with their paths. +* **ios:** Return the Height and Width of selected images along with their paths. + ## [2.0.4](https://github.com/spoonconsulting/cordova-plugin-telerik-imagepicker/compare/2.0.3...2.0.4) (2023-07-12) * **ios:** Use interfaceOrientation for ios 13+. diff --git a/package-lock.json b/package-lock.json index 49a786f9..53c04523 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@spoonconsulting/cordova-plugin-telerik-imagepicker", - "version": "2.0.4", + "version": "2.0.5", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@spoonconsulting/cordova-plugin-telerik-imagepicker", - "version": "2.0.4", + "version": "2.0.5", "license": "MIT", "engines": { "name": "cordova", diff --git a/package.json b/package.json index 26a0a33b..54af4a13 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@spoonconsulting/cordova-plugin-telerik-imagepicker", - "version": "2.0.4", + "version": "2.0.5", "cordova_name": "ImagePicker", "description": "This plugin allows selection of multiple images from the camera roll / gallery in a phonegap app", "license": "MIT", diff --git a/plugin.xml b/plugin.xml index 01185328..58bd3897 100644 --- a/plugin.xml +++ b/plugin.xml @@ -2,7 +2,7 @@ + version="2.0.5"> ImagePicker From 554f1f9dc80d75441911287dd2a9270e58b9c6f2 Mon Sep 17 00:00:00 2001 From: parveshneedhoo Date: Fri, 10 Nov 2023 12:10:04 +0400 Subject: [PATCH 08/12] JS-DevTools/npm-publish@v3 --- .github/workflows/npm-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index c287ca1a..fc9f1df2 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -7,7 +7,7 @@ jobs: - uses: actions/checkout@v2 - uses: bahmutov/npm-install@v1 - id: publish - uses: JS-DevTools/npm-publish@v2 + uses: JS-DevTools/npm-publish@v3 with: token: ${{ secrets.npm_token }} From d3fff70137f9c030b74ec9eb6395b27d7a255662 Mon Sep 17 00:00:00 2001 From: parveshneedhoo Date: Fri, 10 Nov 2023 12:13:22 +0400 Subject: [PATCH 09/12] JS-DevTools/npm-publish@v2 --- .github/workflows/npm-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index fc9f1df2..c287ca1a 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -7,7 +7,7 @@ jobs: - uses: actions/checkout@v2 - uses: bahmutov/npm-install@v1 - id: publish - uses: JS-DevTools/npm-publish@v3 + uses: JS-DevTools/npm-publish@v2 with: token: ${{ secrets.npm_token }} From 9e37c9b34a9aaa4b979b7e375e41b0d1dded07a3 Mon Sep 17 00:00:00 2001 From: parveshneedhoo Date: Fri, 10 Nov 2023 12:20:41 +0400 Subject: [PATCH 10/12] update readme --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1f686a28..59beaca3 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,9 @@ Example - Get Full Size Images (all default options): window.imagePicker.getPictures( function(results) { for (var i = 0; i < results.length; i++) { - console.log('Image URI: ' + results[i]); + console.log('Image URI: ' + results[i].path); + console.log('Image Height: ' + results[i].height); + console.log('Image Width: ' + results[i].width); } }, function (error) { console.log('Error: ' + error); @@ -41,6 +43,8 @@ window.imagePicker.getPictures( function(results) { for (var i = 0; i < results.length; i++) { console.log('Image URI: ' + results[i]); + console.log('Image Height: ' + results[i].height); + console.log('Image Width: ' + results[i].width); } }, function (error) { console.log('Error: ' + error); From ecd25a0015d94381cc20b825119fa64c85c9e47b Mon Sep 17 00:00:00 2001 From: parveshneedhoo Date: Fri, 10 Nov 2023 12:25:26 +0400 Subject: [PATCH 11/12] correction in readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 59beaca3..4c299ae5 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ Example - Get at most 10 images scaled to width of 800: window.imagePicker.getPictures( function(results) { for (var i = 0; i < results.length; i++) { - console.log('Image URI: ' + results[i]); + console.log('Image URI: ' + results[i].path); console.log('Image Height: ' + results[i].height); console.log('Image Width: ' + results[i].width); } From 01ed793818b41235e6f02ae2e15d9b9d90346291 Mon Sep 17 00:00:00 2001 From: parveshneedhoo Date: Fri, 10 Nov 2023 13:58:06 +0400 Subject: [PATCH 12/12] trigger-publish