Main menu:

Site search

Feeds

Categories

April 2014
S M T W T F S
« Mar    
 12345
6789101112
13141516171819
20212223242526
27282930  

Archive

jhove and mix

I’ve been meaning to write about using jhove to get mix records for some time now, and I promised some folks on the metadatalibrarians list that I would, so here it is (finally!).

MIX, as you may or may not know, is “an XML schema for a set of technical data elements required to manage digital image collections.” Read more about it here. At MPOW we are starting to generate MIX records for all our digital images, mainly for preservation purposes, but we may come up with some other nefarious uses for them later.

So, given that much of the data in a MIX record is obscure and esoteric and never intended for human creation or consumption, how does one create MIX records? Not by hand, that’s for sure. You can hack something together with Perl Magick, but that tends to be pretty labor intensive, and hard to get right. Our Metadata Steering Group* here has spent quite a few hours wrestling with this method and I think we’re about to give up.

A better solution, toward which we are incrementally moving, is to let the nice folks at JHOVE do most of the work for us. JHOVE (JSTOR/Harvard Object Validation Environment) is a piece of software that can validate various digital image formats and extract information about them. If you have an image and you don’t know what format it’s in, you can point JHOVE at it and it will tell you the format. Better yet, it will tell you whether it is valid, and it can tell you a bunch of other info, too.

Here is a full JHOVE record for a page from the original newspaper edition of Uncle Tom’s Cabin. You can see in the middle a bunch of text in the mix namespace. That’s a valid MIX record.

So, if you have a folder full of images and you want to make MIX records for them all, do something like this on a bash command line:

for i in *.jpg
do
/full/path/to/jhove -h xml $i -o /full/path/to/metadatadir/$i.xml
done

Now you have a directory full of jhove files, and you need to turn them into MIX records only. Here’s how I did it. I created a folder and I put several things in it:

  1. xerces-j – I used xerces 2.7.1 and it looks like they are now up to 2.8.0. Just download the whole thing and unpack it so you have a folder called xerces-version#.
  2. An XSL transformation to extract the mix section of the jhove records. Mine is called jhove2mix.xsl and it looks like this:
    <?xml version=“1.0″ encoding=“UTF-8″?>
    <xsl:stylesheet xmlns:xsl=“http://www.w3.org/1999/XSL/Transform” xmlns:mix=“http://www.loc.gov/mix/” version=“1.0″ exclude-result-prefixes=“mix”>
        <xsl:template match=“/”>
            <xsl:apply-templates select=“//mix:mix”/>
        </xsl:template>
        <xsl:template match=“mix:mix”>
            <xsl:copy-of select=“.”/>
        </xsl:template>
    </xsl:stylesheet>
  3. A copy of the MIX schema, available here.
  4. Another bash script to tie it all together. Mine is called jhove2mix.sh and it looks like this:
    #!/bin/bash

    export XERCES=./xerces-2_1_7
    export CLASSPATH=$XERCES/xalan.jar:$XERCES/serializer.jar:$XERCES/xml-apis.jar:$XERCES/xercesImpl.jar:$CLASSPATH
    echo $CLASSPATH

    echo Type the full directory path of jhove .xml files; read dir

    for i in $dir/*.xml
    do
            echo $i
            java org.apache.xalan.xslt.Process -IN $i -XSL jhove2mix.xsl -OUT $i.mix
    done

Run the shell script (./jhove2mix.sh) and it will prompt you for the location of the jhove xml files, read them all in, and write out the mix extractions to the same directory, with .mix appended to the end. Renaming all the files appropriately is left as an exercise for the reader.

I realize this might be pitched low for experienced programmers, and pitched a little high for non-programming metadata librarians, but if you’re trying to get it to work and need some extra help feel free to contact me. We’re all in this mess together, after all.

One more thing: For some images, perhaps images that have been processed a few times, jhove won’t tell you anything other than the fact that the image is valid or invalid. I don’t know why this is, and I’m currently looking into it. If anyone out there can cast any light on this question, please let me know.

*The Metadata Steering Group is commonly referred to as “MSG.” Our motto is “We add flavor and give you a headache.” How great is that?

Write a comment