首頁  >  問答  >  主體

objective-c - 新增Exif資訊為什麼會增加照片Data大小?

NSData *imageData = UIImageJPEGRepresentation(image, 0.4);
CGImageSourceRef source = CGImageSourceCreateWithData((__bridge     CFDataRef)imageData, NULL);
NSMutableDictionary *metaDataDic = [self getEXIF:imageData];
NSMutableDictionary *exifDic = [[metaDataDic objectForKey:(NSString*)kCGImagePropertyExifDictionary] mutableCopy];
NSMutableDictionary *GPSDictionary = [[metaDataDic objectForKey:(NSString*)kCGImagePropertyGPSDictionary] mutableCopy];

if(!exifDic) { exifDic = [NSMutableDictionary dictionary]; }
if(!GPSDictionary) { GPSDictionary = [NSMutableDictionary dictionary]; }

NSTimeZone    *timeZone   = [NSTimeZone timeZoneForSecondsFromGMT:8*3600];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setTimeZone:timeZone];
[formatter setDateFormat:@"YYYY:MM:dd hh:mm:ss"];
NSString *now = [formatter stringFromDate:[NSDate date]];
[exifDic setObject:now forKey:(NSString *)kCGImagePropertyExifDateTimeOriginal];

[metaDataDic setObject:exifDic forKey:(NSString*)kCGImagePropertyExifDictionary];

CFStringRef UTI = CGImageSourceGetType(source);
NSMutableData *newImageData = [NSMutableData data];
CGImageDestinationRef destination = CGImageDestinationCreateWithData((__bridge CFMutableDataRef)newImageData, UTI, 1, NULL);

CGImageDestinationAddImageFromSource(destination, source, 0, (__bridge CFDictionaryRef)metaDataDic);
CGImageDestinationFinalize(destination);

如果imageData初始值為69091bytes,添加Exif資訊後會變成114691bytes,我並不想添加Exif資訊後增加這麼大的資料size,請問這是什麼原因?

给我你的怀抱给我你的怀抱2698 天前661

全部回覆(0)我來回復

無回覆
  • 取消回覆