Write IPTC data to file

前端 未结 2 1901
有刺的猬
有刺的猬 2021-01-06 17:02

I would need to take an existing jpg file and modify the title, the description and the keywords in its IPTC entries. There are several topics here on this but all either wi

2条回答
  •  醉梦人生
    2021-01-06 17:57

    you should use XMP Toolkit SDK, you can find detailed information at adobe SDK page implementing is little bit tricky but once you add static libraries to your project you can read and write XMP information, it covers IPTC namespace as well upon others namespaces as like dublin-core etc.

    After you add libraries to project code like this.

    #include "XMP.incl_cpp"
    #include "XMP.hpp"
    #include 
    #include 
    #include 
    #include 
    
    -(void)readIPTC
    {
        SXMPMeta::Initialize()
        SXMPMeta imageMeta;
    
        if(imageMeta.DoesPropertyExist(kXMP_NS_DC, "title"))
        {
            std::string MyString;
            imageMeta.GetArrayItem(kXMP_NS_DC, "title", 1, &MyString, 0);
            [textField setStringValue:[NSString stringWithCString:MyString.c_str() encoding:[NSString defaultCStringEncoding]]];
        }
    }
    

    writing is pretty much same.

    imageMeta.SetProperty(<#XMP_StringPtr schemaNS#>, <#XMP_StringPtr propName#>, <#XMP_StringPtr propValue#>)
    

    you can find all namespace constants in documentation as like kXMP_NS_DC XMP NameSpace DublinCore etc.

    Apple's Image/IO suppose to cover all but for instance you can read byline entry from IPTC with Image/IO however you can't write it.

    Image/IO Reference

    CGImageProperties Reference

提交回复
热议问题