Return-Path: X-Original-To: apmail-cordova-dev-archive@www.apache.org Delivered-To: apmail-cordova-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8AEED18FF0 for ; Thu, 10 Mar 2016 21:15:55 +0000 (UTC) Received: (qmail 11262 invoked by uid 500); 10 Mar 2016 21:15:55 -0000 Delivered-To: apmail-cordova-dev-archive@cordova.apache.org Received: (qmail 11227 invoked by uid 500); 10 Mar 2016 21:15:55 -0000 Mailing-List: contact dev-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list dev@cordova.apache.org Received: (qmail 11216 invoked by uid 99); 10 Mar 2016 21:15:55 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 Mar 2016 21:15:55 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id E7D7EDFA6F; Thu, 10 Mar 2016 21:15:54 +0000 (UTC) From: omefire To: dev@cordova.apache.org Reply-To: dev@cordova.apache.org References: In-Reply-To: Subject: [GitHub] cordova-plugin-camera pull request: [iOS] Major refactor Content-Type: text/plain Message-Id: <20160310211554.E7D7EDFA6F@git1-us-west.apache.org> Date: Thu, 10 Mar 2016 21:15:54 +0000 (UTC) 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 infrastructure@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org For additional commands, e-mail: dev-help@cordova.apache.org