Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 75428107E7 for ; Thu, 25 Apr 2013 23:37:28 +0000 (UTC) Received: (qmail 20413 invoked by uid 500); 25 Apr 2013 23:37:28 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 20345 invoked by uid 500); 25 Apr 2013 23:37:28 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: callback-dev@cordova.apache.org Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 20328 invoked by uid 99); 25 Apr 2013 23:37:27 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 25 Apr 2013 23:37:27 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id BB1D988193D; Thu, 25 Apr 2013 23:37:27 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: lorinbeer@apache.org To: commits@cordova.apache.org Date: Thu, 25 Apr 2013 23:37:27 -0000 Message-Id: <040ce8dd0ecb4766ba3473230b28a555@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/3] ios commit: [CB-2896] initial migration of Sebastien Burel's exif solution Updated Branches: refs/heads/master 3586d6cc2 -> 944912878 [CB-2896] initial migration of Sebastien Burel's exif solution Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/20a8b960 Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/20a8b960 Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/20a8b960 Branch: refs/heads/master Commit: 20a8b96039ff65a7033f92afb01cda1db0383756 Parents: 3586d6c Author: sburel Authored: Thu Apr 25 14:54:24 2013 -0700 Committer: lorinbeer Committed: Thu Apr 25 16:29:24 2013 -0700 ---------------------------------------------------------------------- CordovaLib/Classes/CDVCamera.h | 2 +- CordovaLib/Classes/CDVCamera.m | 52 ++++++++++++++++++++++++++++++++++- 2 files changed, 52 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/20a8b960/CordovaLib/Classes/CDVCamera.h ---------------------------------------------------------------------- diff --git a/CordovaLib/Classes/CDVCamera.h b/CordovaLib/Classes/CDVCamera.h index 2ff4567..b093a21 100644 --- a/CordovaLib/Classes/CDVCamera.h +++ b/CordovaLib/Classes/CDVCamera.h @@ -66,7 +66,7 @@ typedef NSUInteger CDVMediaType; {} @property (strong) CDVCameraPicker* pickerController; - +@property (strong) NSMutableDictionary *metadata; /* * getPicture * http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/20a8b960/CordovaLib/Classes/CDVCamera.m ---------------------------------------------------------------------- diff --git a/CordovaLib/Classes/CDVCamera.m b/CordovaLib/Classes/CDVCamera.m index ab2e336..ffad907 100644 --- a/CordovaLib/Classes/CDVCamera.m +++ b/CordovaLib/Classes/CDVCamera.m @@ -22,6 +22,11 @@ #import "NSArray+Comparisons.h" #import "NSData+Base64.h" #import "NSDictionary+Extensions.h" +#import +#import +#import +#import +#import #import #define CDV_PHOTO_PREFIX @"cdv_photo_" @@ -307,8 +312,53 @@ static NSSet* org_apache_cordova_validArrowDirections; /* splice loc */ CDVJpegHeaderWriter* exifWriter = [[CDVJpegHeaderWriter alloc] init]; NSString* headerstring = [exifWriter createExifAPP1:[info objectForKey:@"UIImagePickerControllerMediaMetadata"]]; - data = [exifWriter spliceExifBlockIntoJpeg:data withExifBlock:headerstring]; + // data = [exifWriter spliceExifBlockIntoJpeg:data withExifBlock:headerstring]; + + + //NSMutableDictionary *metadata; + NSDictionary *controllerMetadata = [info objectForKey:@"UIImagePickerControllerMediaMetadata"]; + if (controllerMetadata) { + self.metadata = [[NSMutableDictionary alloc] init]; + NSMutableDictionary *EXIFDictionary = [[controllerMetadata objectForKey:(NSString *)kCGImagePropertyExifDictionary]mutableCopy]; + if (EXIFDictionary) { + [self.metadata setObject:EXIFDictionary forKey:(NSString *)kCGImagePropertyExifDictionary]; + } + + //[[self locationManager] startUpdatingLocation]; + } + /* + else { + NSURL *url = [info objectForKey:UIImagePickerControllerReferenceURL]; + if (url) { + void (^retreiveAssetMetadata)(ALAsset *) = ^(ALAsset *asset) { + self.metadata = [[NSMutableDictionary alloc] init]; + + NSMutableDictionary *EXIFDictionary = [[asset.defaultRepresentation.metadata objectForKey:(NSString *)kCGImagePropertyExifDictionary]mutableCopy]; + NSMutableDictionary *GPSDictionary = [[asset.defaultRepresentation.metadata objectForKey:(NSString *)kCGImagePropertyGPSDictionary]mutableCopy]; + if (EXIFDictionary) [self.metadata setObject:EXIFDictionary forKey:(NSString *)kCGImagePropertyExifDictionary]; + if (GPSDictionary) [self.metadata setObject:GPSDictionary forKey:(NSString *)kCGImagePropertyGPSDictionary]; + + // [self imagePickerControllerReturnImageResult]; + }; + + ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init]; + [library assetForURL:url resultBlock:retreiveAssetMetadata failureBlock:^(NSError *error) {}]; + } + } + */ + CGImageSourceRef sourceImage = CGImageSourceCreateWithData((__bridge_retained CFDataRef)data, NULL); + CFStringRef sourceType = CGImageSourceGetType(sourceImage); + + CGImageDestinationRef destinationImage = CGImageDestinationCreateWithData((__bridge CFMutableDataRef)data, sourceType, 1, NULL); + CGImageDestinationAddImageFromSource(destinationImage, sourceImage, 0, (__bridge CFDictionaryRef)self.metadata); + CGImageDestinationFinalize(destinationImage); + + CFRelease(sourceImage); + CFRelease(destinationImage); } +// [self imagePickerControllerReturnImageResult]; + + if (cameraPicker.saveToPhotoAlbum) { UIImageWriteToSavedPhotosAlbum([UIImage imageWithData:data], nil, nil, nil);