To www-rdf-interest about XMP and JPEGs

August 3rd, 2002  |  Published in photos, rdf  |  2 Comments

A mail sent to www-rdf-interest after attempting to embed XMP metadata in JPEGs.

(It turns out my code doesn’t do the jpeg embedding quite right. It looks like the JPEG-XMP package will do it correctly.)

Subject: Adobe XMP and jpeg embedding
Date: 03 Aug 2002 19:18:39 +0100

I was discussing picture metadata with some people this morning and
decided to have a play with the Adobe XMP toolkit [1]. Here are my
notes, in case they are of use or interest to anyone.

job 1: compile under linux, which is unsupported
* the code compiles with warnings if you apply these small
changes across the .c, .cpp and .h files:
* s/xap_xpdomconf.h/XAP_XPDOMConf.h/g
* s/XPDom.h/XPDOM.h/g
* s/XAPTkinternals.h/XAPTkInternals.h/g
* tsk tsk to adobe for developing on a case-insensitive OS but
putting mixed-case filenames in their zipfiles
* also, some files use FREE, REALLOC, CALLOC and MALLOC macros
which presumably would get correctly resolved via a chain of ifdefs
and stuff if i were on windows, but for now just #define them to
regular libc free, realloc, calloc and malloc
* then compile everything with gcc/g++ version 3
* i should make a Makefile really, but i’m too dumb so I just
muck about on the cmdline
* the sample XAPDumper also needs the PacketScanner utility to
compile, but that’s also in the distribution and compiles OK
(perhaps with similar case-changes for include files)
* having done this, i end up with a bunch of apparently
working code, but I am getting some segfaults on exit
* i shall run a memory profiler when i get a round tuit

job 2: try the dumper
* as you’d hope, the PDF files that document the XMP toolkit
themselves have XMP embedded
* so I ran the dumper on XMPEmbedding.pdf and got this dump [2]
* and here’s a nice w3c rdf validator visualisation of the
metadata [3]

job 3: insert XMP into JPEG as described in XMPEmbedding.pdf
* now, time to write some C++ using the toolkit
* I used the MetaXAP object to create a new chunk of rdf
describing a jpeg as having dc:creator David Brophy
* that gets rendered to RDF/XML and the UtilityXAP object
creates an ‘xml packet’ wrapper around the metadata
* i now have a string ready to insert into a jpeg
* i use libexif5 and something named ‘libjpeg’ extracted from
the source distribution of the ‘exif’ command to add data to the
existing jpeg file
* this goes in an APP1 segment that starts with a length value
and the null-terminated string ‘‘,
followed by the
<?xpacket begin=’\x{FEFF}’ id=’W5M0MpCehiHzreSzNTczkc9d’?>

<?xpacket end=’w’ ?>
wrapper created by the toolkit
* the resulting jpeg [4] still renders correctly as a jpeg,
and also contains xmp data giving dc:creator as David Brophy
* and works as expected with dan brickley’s XMP demo:
* extracted metadata: [5], raw RDF/XML: [6]
* the slightly shoddy code that does job 3 is available [7]






  1. propecia says:

    April 14th, 2004 at 9:01 pm (#)

    Yong Artist! propecia

  2. viagra says:

    April 14th, 2004 at 9:02 pm (#)

    Yong Artist! viagra