相关疑难解决方法(0)

问题设置图像的exif数据

我在iOS 4.1中使用新的ImageIO框架.我使用以下代码成功检索exif元数据:

CFDictionaryRef metadataDict = CMGetAttachment(sampleBuffer, kCGImagePropertyExifDictionary , NULL);
Run Code Online (Sandbox Code Playgroud)

阅读它,它似乎是有效的.保存图像有效,但图像中从不存在任何exif数据.

    CGImageDestinationRef myImageDest = CGImageDestinationCreateWithURL((CFURLRef) docurl, kUTTypeJPEG, 1, NULL);

    // Add the image to the destination using previously saved options. 
    CGImageDestinationAddImage(myImageDest, iref, NULL);

    //add back exif
    NSDictionary *props = [NSDictionary dictionaryWithObjectsAndKeys:
                            [NSNumber numberWithFloat:.1], kCGImageDestinationLossyCompressionQuality,
                           metadataDict, kCGImagePropertyExifDictionary, //the exif metadata
                                                        nil];

                          //kCGImagePropertyExifAuxDictionary

    CGImageDestinationSetProperties(myImageDest, (CFDictionaryRef) props);

    // Finalize the image destination. 
    bool status = CGImageDestinationFinalize(myImageDest);
Run Code Online (Sandbox Code Playgroud)

iphone macos exif core-graphics javax.imageio

55
推荐指数
3
解决办法
3万
查看次数

标签 统计

core-graphics ×1

exif ×1

iphone ×1

javax.imageio ×1

macos ×1