cari

Rumah  >  Soal Jawab  >  teks badan

Objektif-c - Mengapa menambah maklumat Exif meningkatkan saiz Data foto?

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);

Jika nilai awal imageData ialah 69091bait, ia akan menjadi 114691bait selepas menambah maklumat Exif Saya tidak mahu meningkatkan saiz data yang begitu besar selepas menambah maklumat Exif.

给我你的怀抱给我你的怀抱2803 hari yang lalu748

membalas semua(0)saya akan balas

Tiada jawapan
  • Batalbalas