[ https://issues.apache.org/jira/browse/CB-13950?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16388678#comment-16388678 ]
Junran commented on CB-13950: ----------------------------- User Text to keep the line change: - (NSData*)processImage:(UIImage*)image info:(NSDictionary*)info options:(CDVPictureOptions*)options { NSData* data = nil; switch (options.encodingType) { case EncodingTypePNG: data = UIImagePNGRepresentation(image); break; case EncodingTypeJPEG: { if ((options.allowsEditing == NO) && (options.targetSize.width <= 0) && (options.targetSize.height <= 0) && (options.correctOrientation == NO) && (([options.quality integerValue] == 100) || (options.sourceType != UIImagePickerControllerSourceTypeCamera))){ // use image unedited as requested , don't resize data = UIImageJPEGRepresentation(image, 1.0); } else { data = UIImageJPEGRepresentation(image, [options.quality floatValue] / 100.0f); } //if (options.usesGeolocation) { NSURL *assetURL = [info objectForKey:UIImagePickerControllerReferenceURL]; //NSDictionary *metadata =[info objectForKey:UIImagePickerControllerMediaMetadata]; ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init]; dispatch_semaphore_t sema = dispatch_semaphore_create(0); dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0); dispatch_async(queue, ^{[library assetForURL:assetURL resultBlock:^(ALAsset *asset) { NSDictionary *controllerMetadata = asset.defaultRepresentation.metadata; //NSLog(@"metadatacontrol %@", controllerMetadata); //NSDictionary* controllerMetadata = [info objectForKey:@"UIImagePickerControllerMediaMetadata"]; if (controllerMetadata) { self.data = data; self.metadata = [[NSMutableDictionary alloc] init]; NSMutableDictionary *metadataAsMutable = [controllerMetadata mutableCopy]; //NSMutableDictionary* EXIFDictionary = [[metadataAsMutable objectForKey:(NSString*)kCGImagePropertyExifDictionary]mutableCopy]; NSMutableDictionary *EXIFDictionary = [[metadataAsMutable objectForKey:(NSString *)kCGImagePropertyExifDictionary]mutableCopy]; NSMutableDictionary *GPSDictionary = [[metadataAsMutable objectForKey:(NSString *)kCGImagePropertyGPSDictionary]mutableCopy]; NSMutableDictionary *RAWDictionary = [[metadataAsMutable objectForKey:(NSString *)kCGImagePropertyRawDictionary]mutableCopy]; if(!EXIFDictionary) EXIFDictionary = [[NSMutableDictionary dictionary] init]; if(!GPSDictionary) GPSDictionary = [[NSMutableDictionary dictionary] init]; if(!RAWDictionary) RAWDictionary = [[NSMutableDictionary dictionary] init]; //Add the modified Data back into the image’s metadata [self.metadata setObject:EXIFDictionary forKey:(NSString *)kCGImagePropertyExifDictionary]; [self.metadata setObject:GPSDictionary forKey:(NSString *)kCGImagePropertyGPSDictionary]; [self.metadata setObject:RAWDictionary forKey:(NSString *)kCGImagePropertyRawDictionary]; //NSLog(@"enter gpsdictionary %@", GPSDictionary); //NSLog(@"enter exifdictionary %@", EXIFDictionary); //NSLog(@"enter rawdictionary %@", RAWDictionary); //NSLog(@"enter self.metadata %@", self.metadata); if (self.metadata) { //this will be the data CGImageDestinationRef will write into NSMutableData *newImageData = [NSMutableData data]; CGImageSourceRef sourceImage = CGImageSourceCreateWithData((__bridge CFDataRef)self.data, NULL); CFStringRef sourceType = CGImageSourceGetType(sourceImage); CGImageDestinationRef destinationImage = CGImageDestinationCreateWithData((__bridge CFMutableDataRef)newImageData, sourceType, 1, NULL); CGImageDestinationAddImageFromSource(destinationImage, sourceImage, 0, (__bridge CFDictionaryRef)self.metadata); CGImageDestinationFinalize(destinationImage); //CIImage *testImage = [CIImage imageWithData:newImageData]; self.data = newImageData; CFRelease(sourceImage); CFRelease(destinationImage); dispatch_semaphore_signal(sema); } //if (EXIFDictionary) {NSLog(@"enter exifdictionary %@", EXIFDictionary); // [self.metadata setObject:EXIFDictionary forKey:(NSString*)kCGImagePropertyExifDictionary]; //} //if (IsAtLeastiOSVersion(@"8.0")) { // [[self locationManager] performSelector:NSSelectorFromString(@"requestWhenInUseAuthorization") withObject:nil afterDelay:0]; //} //[[self locationManager] startUpdatingLocation]; } } failureBlock:^(NSError *error) { dispatch_semaphore_signal(sema); }]; }); dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER); return self.data; //} } break; default: break; }; return data; } > All Exif data is stripped off under iOS when Camera.DestinationType is > File_URI > ------------------------------------------------------------------------------- > > Key: CB-13950 > URL: https://issues.apache.org/jira/browse/CB-13950 > Project: Apache Cordova > Issue Type: Bug > Components: cordova-plugin-camera > Affects Versions: cordova-ios 4.5.0 > Reporter: Junran > Priority: Major > > When Camera.DestinationType is File_URI > All exif metadata is stripped off under iOS > This is inconsistent with what it is under Android. It seems the code have > implemented to reattached the exif metadata when writing to temporary file > path, but it doesn't work. > A way to retain the exif data when using File_URI under iOS is needed. > Any idea is much appreciated. Thanks! -- This message was sent by Atlassian JIRA (v7.6.3#76005) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org For additional commands, e-mail: issues-h...@cordova.apache.org