> Essays > coding > EditPhotoMetaData
> Essays > coding > EditPhotoMetaData
by ZweiBieren Changing Photo Metadata pens in a mug

(This note is a cleaned up version of Adobe Forum post https://forums.adobe.com/thread/291056. No one has responded.)

My problem seemed simple: I have computed a property of an image and I want to insert that property into the image's metadata. Looking at the existing metadata I see an xpacket with all sorts of neatly recorded data. To this I want to add something simple like:

     colorSwatch: 0xFF00BB

Question 1: Will the metadata be harmed by inserting some text as long as I delete an equal number of the pre-existing blanks? Is there a checksum? Do I really have to use the XMP SDK and program in C?

So I started reading. Alphabet soup: XMP DC RDF RDFS . . . No one seems to appreciate the value of a little working example. Eventually I pieced together the approach below.

Question 2: Has the following scheme a prayer of doing anything useful? Step one - Define the pixa:color tag. This is in physpics.com/namespace/pixa.rdf:

<?xml version="1.0" encoding="utf-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
<rdfs:Class rdf:ID="Color">
<rdfs:subClassOf rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#Resource"/>
</rdfs:Class>
<rdfs:simpleType name='colordata'>
<rdfs:restriction base='hexBinary'>
<rdfs:length value='6' />
</rdfs:restriction>
</rdfs:simpleType>
<rdf:Property rdf:ID="color">
<rdfs:comment>Color swatch value for a picture</rdfs:comment>
<rdfs:domain rdf:resource=""/>
<rdfs:comment> ? </rdfs:comment>
<rdfs:range rdf:datatype="colordata" />
</rdf:Property> </rdf:RDF>

Question 3: What is the domain? It should somehow be a reference to an xpacket, I guess.

Step two - Add the pixa namespace to the rdf:Description. The head of the xpacket would look like.

<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?>  
    <x:xmpmeta xmlns:x="adobe:ns:meta/"   x:xmptk="3.1.2-114">
        <rdf:RDF   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
            xmlns:pa="http://physpics.com/namespace/pixa.rdf#">
          <rdf:Description rdf:about=""/>
        </rdf:RDF>
    </x:xmpmeta>

Step three - code the insertion for the xpacket. I believe (anyway, hope) that the packet looks like this:

  <dc:description>
      <rdf:Alt>
          <rdf:li>
              <pixa:color>0xFF00BB</pixa:color>
          </rdf:li>
</rdf:Alt>
</dc:description>

Phew. That's it. Will it work????

Thanks for taking the time to work through this.
Fred Hansen

 
Copyright © 2018 ZweiBieren, All rights reserved. Jun 28, 2018 18:00 GMT Page maintained by ZweiBieren