XMP Toolkit SDK

repository·main·Indexed 42 days ago

https://github.com/adobe/xmp-toolkit-sdk

A C++ library for integrating Extensible Metadata Platform (XMP) functionality into products. It consists of XMPCore for parsing and manipulating metadata according to the XMP data model, and XMPFiles for locating and updating metadata within specific files. The SDK includes an XMPFiles Plug-in SDK for custom format handlers and supports multiple platforms including Windows, Mac OS, UNIX/Linux, iOS, and Android.

Tokens
2.4K
Snippets
5
Records
13
Agent score
53%

What's inside XMP Toolkit SDK

  1. Understand the XMP Toolkit SDK components

    main

    The XMP Toolkit SDK is composed of two primary C++ libraries that work together to manage metadata:

    1. XMPCore: Provides the API for parsing, manipulating, and serializing metadata according to the XMP data model. It is format-agnostic, meaning it handles the metadata logic regardless of the file format being described.
    2. XMPFiles: Provides the API for locating, adding, or updating XMP metadata within specific files. It allows you to retrieve an entire XMP Packet, which can then be passed to XMPCore for property-level manipulation.

    XMPFiles Plug-in SDK: Included within the XMPFiles component, this allows you to create plug-ins to handle metadata for additional file formats or to replace built-in format handlers with custom ones.

  2. Review XMP Specification parts

    main

    Before using the SDK, you should be familiar with the XMP Data Model. The XMP Specification is divided into three parts:

    • Part 1: Data Model, Serialization, and Core Properties: Covers the basic metadata representation model, how metadata is organized (Data Model), and how it is represented in XML/RDF (Serialization Model).
    • Part 2: Additional Properties: Provides property lists and descriptions for standard schemas (e.g., Dublin Core) and Adobe-specific schemas (e.g., Photoshop), as well as instructions for creating new schemas.
    • Part 3: Storage in Files: Explains how serialized XMP metadata is packaged into XMP Packets and embedded into various file formats, including how to reconcile multiple metadata formats.
  3. Build the XMP Toolkit SDK

    main

    The SDK provides build scripts to facilitate the creation of project files across multiple platforms, including Mac OS®, Windows®, UNIX®/Linux®, iOS, and Android.

    To build the SDK:

    1. Navigate to the build/ directory.
    2. Use the provided Batch files, shell scripts, Makefiles, or CMake scripts to generate the appropriate project files for your platform.
    3. Follow the specific instructions located in build/README.txt to complete the project creation process.

    For a detailed, step-by-step walkthrough of the build process, refer to the Programmer's Guide.

  4. Set up CMake for building the XMP Toolkit

    main

    The XMP Toolkit uses CMake to generate standard build files from the CMakeLists.txt files located in the source directories. To prepare the build environment, you must download a specific version of CMake and place it within the SDK directory structure.

    Requirements:

    • Minimum CMake version: 3.15.5

    Installation Steps:

    1. Download CMake 3.15.5 from the official distribution links:

      • Windows: https://cmake.org/files/v3.15/cmake-3.15.5-win32-x86.zip
      • Mac OSX: https://cmake.org/files/v3.15/cmake-3.15.5-Darwin-x86_64.tar.gz
      • Linux: https://cmake.org/files/v3.15/cmake-3.15.5-Linux-x86_64.tar.gz
    2. Place files in the SDK directory (<xmpsdk>/tools/cmake/):

      • Windows and Linux: Copy the /bin and /share folders from the downloaded package into <xmpsdk>/tools/cmake/.
      • Mac OSX: a) Create the directory <xmpsdk>/tools/cmake/bin. b) Rename the CMake application to cmake.app and copy it into that directory.
  5. Configure Expat as the XML parser for XMP Toolkit

    main

    The XMP Toolkit requires an external XML parser to function. While the Adobe source is written specifically for Expat, the architecture allows for adapters to be written for other parsers. To use Expat, you must provide the Expat distribution files in a specific directory structure within the SDK.

    Requirements:

    • An Expat distribution (version 2.5.0 is the most recent version used with XMP).
    • The Expat lib directory must be placed within the third-party/expat directory of the XMP Toolkit SDK (as a sibling to this README file).
  6. Set up Android build tools for XMP Toolkit SDK

    main

    To build Android binaries for the XMP Toolkit SDK, you must install and configure CMake, Ninja, and the Android NDK.

    Required Tools

    1. CMake (version 3.6.4111459): Can be installed via the Android Studio SDK Manager or downloaded directly.
    2. Ninja: This executable is included within the CMake distribution (located at <cmakeroot>/bin/ninja).
    3. NDK (version 19c): Can be installed via the Android Studio SDK Manager or downloaded directly.

    The XMP Toolkit expects Ndk-bundle, ninja, and cmake to be present in the tools/android directory. You can satisfy this requirement by creating symbolic links to your Android SDK installation paths.

    sudo ln -s /Users/..../Library/Android/sdk/cmake/3.6.4111459/bin/cmake ../tools/android/
    sudo ln -s /Users/..../Library/Android/sdk/ndk-bundle ../tools/android/
    sudo ln -s /Users/..../Library/Android/sdk/cmake/3.6.4111459/bin/ninja ../tools/android/
  7. Obtain and install zlib for XMP Toolkit SDK

    main

    The XMP Toolkit SDK requires zlib (specifically version 1.2.13 is used in this release) to function. To set up the dependency:

    1. Download the zlib source code (not a compiled .dll) from http://www.zlib.net/.
    2. Extract the downloaded archive.
    3. Copy all top-level .c and .h files from the zlib source directly into the .../third-party/zlib directory within the XMP Toolkit SDK project structure.
  8. Configure CMake directory structure for Android builds

    main
    If you choose not to use symbolic links for CMake, you must ensure that the cmake share folder is located parallel to the CMake binary's parent folder. Specifically, the share folder must be placed at tools/ relative to the build environment.
  9. Use the dumpfile utility to inspect file structures

    main

    The dumpfile utility is a developer tool used to view and validate file structures, specifically focusing on metadata. It acts similarly to a hex editor but is more readable.

    Note: dumpfile is NOT a production tool. It does not perform XMP logic reconciliation, handle encoding matters, or extract valid metadata for use in applications. It is intended for structural inspection only.

    # Show key-value nodes as an alphabetical list
    dumpfile -keys Sample.jpg
    
    # Show the hierarchical tree structure (default)
    dumpfile Sample.jpg
    
    # Show key-value nodes in the order they were parsed
    dumpfile -list Sample.jpg
    
    # Suppress comments in the output
    dumpfile -nocomments Sample.jpg
  10. Explore the XMP Toolkit SDK directory structure

    main

    The repository is organized as follows:

    DirectoryDetails
    /Contains BSD_License.txt and the XMP-Toolkit-SDK-Overview.pdf
    build/Build scripts (Batch, shell, Makefile, CMake) for creating project files. See build/README.txt
    docs/XMP Specification, Programmer’s Guide, API reference (API/index.html), and XMPFiles plug-in SDK documentation
    public/include/Essential header files and glue code required by clients
    samples/Sample source code and CMake scripts for building sample projects
    source/Common source code used by both XMPCore and XMPFiles
    XMPCore/Source code for the XMPCore library
    XMPFiles/Source code for the XMPFiles library
    third-party/Third-party dependencies (expat, zlib, zuid). Includes MD5 source code. See individual ReadMe.txt files for installation instructions
    tools/Placeholder for CMake tools
    XMPFilesPlugins/Header files and glue code for the XMPFiles plug-in SDK and a sample plug-in
  11. Initialize and Terminate the XMPCore SDK

    main

    Before using any SXMPMeta functionality, you must initialize the XMPCore library. Once your operations are complete, you must call terminate to clean up resources. Failure to initialize will result in errors when calling other SDK methods.

    // Initialize the SDK
    if (!SXMPMeta::Initialize()) {
        // Handle initialization failure
    }
    
    // ... perform XMP operations ...
    
    // Clean up the SDK
    SXMPMeta::Terminate();