I have a little problem, I follow this thread Problem setting exif data for an image
for save exif on my image, I save a comment, the funciont work, I save the image on my document root
// Documents
NSString *jpgPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Test.jpg"];
[dest_data writeToFile:jpgPath atomically:YES];
// Create file manager
NSError *error;
NSFileManager *fileMgr = [NSFileManager defaultManager];
// Point to Document directory
NSString *documentsDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
// Write out the contents of home directory to console
NSLog(@"Documents directory: %@", [fileMgr contentsOfDirectoryAtPath:documentsDirectory error:&error]);
but when I load the image from document root there is no exif, for load image I use
NSString *jpgPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Test.jpg"];
UIImage *loadedImage = [UIImage imageWithContentsOfFile:jpgPath];
NSData *jpeg = UIImageJPEGRepresentation(loadedImage,1.0);
CGImageSourceRef source ;
source = CGImageSourceCreateWithData((CFDataRef)jpeg, NULL);
NSDictionary *metadataNew = (NSDictionary *) CGImageSourceCopyPropertiesAtIndex(source,0,NULL);
NSLog(@"%@",metadataNew);
I'm sure开发者_如何学运维 that the exif was saved because if I open the image from simulator root the image has the exif data.
Also if I try to upload the image on my server it hasn't exif data. where is the problem?
Read it into the NSData directly, eg:
NSData *jpeg=[[NSData alloc] initWithContentsOfFile:jpgPath];
This will contain the EXIF data.
精彩评论