2

My NSData which contains an image taken from an external hardware has metadata.. I have tested it by uploading the image to AWS.

I have tried these two conversions:

UIImage *image = [UIImage imageWithData:_downloadedImageData ];

UIImage *image = [[UIImage alloc] initWithData:_downloadedImageData];

I have done my research and found out whenever NSData is converted to UIImage or vice versa the metadata (EXIF data) is lost. How do I convert such that my meta exits in both conversion i.e NSData to UIImage and vice versa

Help much appreciated

nynohu
  • 1,628
  • 12
  • 12

1 Answers1

0

Try this code

create path to save the image data.

NSArray *pathArr = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, 
                                                   NSUserDomainMask,
                                                   YES);
NSString *path = [[pathArr objectAtIndex:0]
              stringByAppendingPathComponent:@"_downloadedImageData.data" ];

retrieving the saved data

NSData *retrievedData = [NSData dataWithContentsOfFile:path];
UIImageView *img = [[UIImageView alloc] 
                  initWithFrame:CGRectMake(100, 100, 200, 200)];
img.image = [UIImage imageWithData:retrievedData];
[self.view addSubview:img];
Himanshu Patel
  • 1,015
  • 8
  • 26
  • nope it doesn't work.. i tried all combinations of : [[pathArr objectAtIndex:0] stringByAppendingPathComponent:@"_downloadedImageData.data" ]; [[pathArr objectAtIndex:0] stringByAppendingPathComponent:@"_downloadedImageData" ]; [[pathArr objectAtIndex:0] stringByAppendingPathComponent:@"downloadedImageData.data" ]; [[pathArr objectAtIndex:0] stringByAppendingPathComponent:@"downloadedImageData" ]; – Nithin Reddy Gaddam Jan 06 '17 at 19:33
  • @NithinReddyGaddam Please follow [link](http://stackoverflow.com/questions/7965299/write-uiimage-along-with-metadata-exif-gps-tiff-in-iphones-photo-library) – Himanshu Patel Jan 07 '17 at 05:17