cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lorinb...@apache.org
Subject [1/3] ios commit: [CB-2896] initial migration of Sebastien Burel's exif solution
Date Thu, 25 Apr 2013 23:37:27 GMT
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 <sb@haruni.net>
Authored: Thu Apr 25 14:54:24 2013 -0700
Committer: lorinbeer <lorin@adobe.com>
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 <ImageIO/CGImageProperties.h>
+#import <AssetsLibrary/ALAssetRepresentation.h>
+#import <ImageIO/CGImageSource.h>
+#import <ImageIO/CGImageProperties.h>
+#import <ImageIO/CGImageDestination.h>
 #import <MobileCoreServices/UTCoreTypes.h>
 
 #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);


Mime
View raw message