Skip to content

Commit

Permalink
save height and width for ios on picker
Browse files Browse the repository at this point in the history
  • Loading branch information
parveshneedhoo committed Oct 24, 2023
1 parent 86f002b commit 31e222c
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/ios/SOSPicker.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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<result_all.count; i++){
NSDictionary *imageInfo = @{@"path": result_all[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];
}

[self.viewController dismissViewControllerAnimated:YES completion:nil];
Expand Down

0 comments on commit 31e222c

Please sign in to comment.