Github user omefire commented on a diff in the pull request:
https://github.com/apache/cordova-plugin-camera/pull/185#discussion_r55750647
--- Diff: src/ios/CDVCamera.m ---
@@ -398,10 +437,82 @@ - (NSString*)tempFilePath:(NSString*)extension
do {
filePath = [NSString stringWithFormat:@"%@/%@%03d.%@", docsPath,
CDV_PHOTO_PREFIX, i++, extension];
} while ([fileMgr fileExistsAtPath:filePath]);
-
+
return filePath;
}
+- (BOOL) needsResize:(CDVPictureOptions*)options
+{
+ return (options.targetSize.height > 0 && options.targetSize.width > 0);
+}
+
+- (BOOL) needsEdit:(UIImage*)image options:(CDVPictureOptions*)options
+{
+ return options.correctOrientation || [self needsResize:options];
+}
+
+- (BOOL) needsSavingToPhotoAlbum:(UIImage*)image
options:(CDVPictureOptions*)options
+{
+ /*
+ We save to the photo album if:
+ - the option is set
+ - the image is fetch from the camera OR the image has been edited (no
need to duplicate image in the library)
+ */
+ BOOL isSourceCamera = options.sourceType ==
UIImagePickerControllerSourceTypeCamera;
+ BOOL saveToPhotoAlbum = options.saveToPhotoAlbum && ([self
needsEdit:image options:options] || isSourceCamera);
+
+ return saveToPhotoAlbum;
+}
+
+- (void)didReceiveImage:(CDVPictureOptions*)options
info:(NSDictionary*)info
+{
+ UIImage* image = [self retrieveImage:info options:options];
+
+ /*
+ We can send the result immediately if:
+ - we fetch the picture from the PhotoLibrary or the SavedPhotoAlbum,
+ - we don't do any editing (orientation or resize),
+ - we pass down the result as a NATIVE_URI
+ */
+ BOOL needsEdit = [self needsEdit:image options:options];
+ BOOL isSourceCamera = (options.sourceType ==
UIImagePickerControllerSourceTypeCamera);
+ BOOL isDestinationNativeUri = (options.destinationType ==
DestinationTypeNativeUri);
+ BOOL needsMetadata = (needsEdit || isSourceCamera ||
!isDestinationNativeUri);
--- End diff --
I feel like the description given in the 'Metadata' section here could help
clarify things better here, can we add it ?
https://github.com/apache/cordova-plugin-camera/pull/101
"Regarding metadata, we do not need it in only one case, when the
destination type is NATIVE_URI, the source is the library, and no edits have to
be done."
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]