Author Topic: Metadata Files (RDF)  (Read 2370 times)

monochrome

  • Full Member
  • **
  • Posts: 149
Metadata Files (RDF)
« on: March 23, 2015, 04:09:44 PM »
IMatch supports files with embedded metadata and files with metadata in sidecar files.

Can IMatch be made to load metadata embedded in an XML file, where the XML file is not a sidecar to any other file?

(Exiftool seems to display this data fine.)

Mario

  • IMatch Developer
  • Administrator
  • *****
  • Posts: 30082
Re: Metadata Files (RDF)
« Reply #1 on: March 23, 2015, 04:23:50 PM »
I'm not sure that I understand.
When I add an XML file to a database, IMatch indexes the file, and even displays the contents of the XML file in the Quick Preview panel, with proper indentation and highlighting.

Neither IMatch nor ExifTool will do any further analysis of the contents of arbitrary text files or anything, if this is what you expect. Every XML file is different and an application has to understand the XML and the data it contains to process it in any further way. Just that a file is in XML format does not mean a thing. It just tells you that the data in the file is in XML format, but not what the data actually means.

I think what you mean is that ExifTool extracts some of the XML data and displays it when used from the command line? This is not how it works when IMatch uses ExifTool and IMatch does not receive any data for XML files. In command line, ExifTool just dumps the individual nodes in the XML file. This data is of no use for IMatch and cannot be mapped into the metadata tag schema IMatch uses to corporate with ExifTool.

And, please, read the board info before you post. This board is for posting tutorials and for giving other users tips. Not for asking questions. I have moved your post to the General Discussions board.
« Last Edit: March 23, 2015, 04:30:31 PM by Mario »

monochrome

  • Full Member
  • **
  • Posts: 149
Re: Metadata Files (RDF)
« Reply #2 on: March 23, 2015, 04:47:55 PM »
1. Sorry about posting in the wrong board.

2. Exiftool does do further analysis and understands XML files since it recognizes the XML namespaces of the elements. For example, put this (taken from the Wikipedia page about XMP) in a file called "sample.xml":

Code: [Select]
<?xpacket begin="?" id="W5M0MpCehiHzreSzNTczkc9d"?>
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 5.4-c002 1.000000, 0000/00/00-00:00:00        ">
   <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
      <rdf:Description rdf:about=""
            xmlns:xmp="http://ns.adobe.com/xap/1.0/">
         <xmp:CreatorTool>Picasa</xmp:CreatorTool>
      </rdf:Description>
      <rdf:Description rdf:about=""
            xmlns:mwg-rs="http://www.metadataworkinggroup.com/schemas/regions/"
            xmlns:stDim="http://ns.adobe.com/xap/1.0/sType/Dimensions#"
            xmlns:stArea="http://ns.adobe.com/xmp/sType/Area#">
         <mwg-rs:Regions rdf:parseType="Resource">
            <mwg-rs:AppliedToDimensions rdf:parseType="Resource">
               <stDim:w>912</stDim:w>
               <stDim:h>687</stDim:h>
               <stDim:unit>pixel</stDim:unit>
            </mwg-rs:AppliedToDimensions>
            <mwg-rs:RegionList>
               <rdf:Bag>
                  <rdf:li rdf:parseType="Resource">
                     <mwg-rs:Type>Face</mwg-rs:Type>
                     <mwg-rs:Area rdf:parseType="Resource">
                        <stArea:x>0.680921052631579</stArea:x>
                        <stArea:y>0.3537117903930131</stArea:y>
                        <stArea:h>0.4264919941775837</stArea:h>
                        <stArea:w>0.32127192982456143</stArea:w>
                        <stArea:unit>normalized</stArea:unit>
                     </mwg-rs:Area>
                  </rdf:li>
               </rdf:Bag>
            </mwg-rs:RegionList>
         </mwg-rs:Regions>
      </rdf:Description>
      <rdf:Description rdf:about=""
            xmlns:exif="http://ns.adobe.com/exif/1.0/">
         <exif:PixelXDimension>912</exif:PixelXDimension>
         <exif:PixelYDimension>687</exif:PixelYDimension>
         <exif:ExifVersion>0220</exif:ExifVersion>
      </rdf:Description>
   </rdf:RDF>
</x:xmpmeta>
 
<!-- whitespace padding -->
 
<?xpacket end="w"?>

Then run exiftool.exe -a -u sample.xml and you will see that Exiftool correctly parses the XMP metadata in the file:

ExifTool Version Number         : 9.90
File Name                       : sample.xml
Directory                       : .
File Size                       : 2.0 kB
File Modification Date/Time     : 2015:03:23 16:42:55+01:00
File Access Date/Time           : 2015:03:23 16:42:45+01:00
File Creation Date/Time         : 2015:03:23 16:42:45+01:00
File Permissions                : rw-rw-rw-
File Type                       : XMP
MIME Type                       : application/rdf+xml
XMP Toolkit                     : Adobe XMP Core 5.4-c002 1.000000, 0000/00/00-0
0:00:00
Creator Tool                    : Picasa
Region Applied To Dimensions W  : 912
Region Applied To Dimensions H  : 687
Region Applied To Dimensions Unit: pixel
Region Type                     : Face
Region Area X                   : 0.680921052631579
Region Area Y                   : 0.3537117903930131
Region Area H                   : 0.4264919941775837
Region Area W                   : 0.32127192982456143
Region Area Unit                : normalized
Exif Image Width                : 912
Exif Image Height               : 687
Exif Version                    : 0220


I would like somehow to displayed this data in IMatch.

Mario

  • IMatch Developer
  • Administrator
  • *****
  • Posts: 30082
Re: Metadata Files (RDF)
« Reply #3 on: March 23, 2015, 05:04:16 PM »
Add a feature request then.
Since ExifTool makes up the tag names for this on-the-fly, this will require not only IMatch to deal with a large number (potentially endless) number of tag names, but will also require quite a number of changes in many areas. Quite an expensive request. I wonder how many users, except for yourself, will ever have a use for such XML files, which just happen to be XMP sidecar files without a matching image...what are they good for?

monochrome

  • Full Member
  • **
  • Posts: 149
Re: Metadata Files (RDF)
« Reply #4 on: March 23, 2015, 05:23:34 PM »
Add a feature request then.
Since ExifTool makes up the tag names for this on-the-fly,

No it doesn't. Those tag names are not made up on the fly.

this will require not only IMatch to deal with a large number (potentially endless) number of tag names, but will also require quite a number of changes in many areas. Quite an expensive request.

No it doesn't. If IMatch can handle what ExifTool outputs today, it can handle this. All I'm asking is to be able to tell IMatch to treat a given file type as "an image that it may or may not be able to display"- just as it handles, for example, PDF:s. Send it to ExifTool, put whatever data Exiftool extracts into the DB. You already do this for PDFs, and I'd guess for just about every file format.

Mario

  • IMatch Developer
  • Administrator
  • *****
  • Posts: 30082
Re: Metadata Files (RDF)
« Reply #5 on: March 23, 2015, 05:40:34 PM »
Quote
No it doesn't. Those tag names are not made up on the fly.
Nonsense.
When I process one of the XML files used by IMatch with ExifTool, I get output like

[XMP]           Ressource file Dialog table Dialog Ctrl C: Toon enieg tekst:

where

Ressource file Dialog table Dialog Ctrl C

is the tag name produced on the fly from the XML node path in the file. The corresponding XML node is:

<resource_file>
  <dialog_table>
    <dialog>
      <ctrl>
        <c>Toon enieg tekst:</c>
      </ctrl>
    </dialog>
  </dialog_table>


ExifTool just follows the XML node path and builds the tag name on-thy-fly.
In your example above you even use the -u tag to explicitly extract unknown tags.

monochrome

  • Full Member
  • **
  • Posts: 149
Re: Metadata Files (RDF)
« Reply #6 on: March 23, 2015, 05:55:21 PM »
ExifTool just follows the XML node path and builds the tag name on-thy-fly.

No. If it did, it would not parse

<exif:PixelXDimension>912</exif:PixelXDimension>
<exif:PixelYDimension>687</exif:PixelYDimension>


as

Exif Image Width                : 912
Exif Image Height               : 687


It can only do that if it is aware of the XML that it is parsing and connect the namespace/element name to an internal table of tags and descriptive names.

In your example above you even use the -u tag to explicitly extract unknown tags.

The output is the same without the -u switch.


This is what I get with your sample file, BTW:

ExifTool Version Number         : 9.90
File Name                       : sample2.xml
Directory                       : .
File Size                       : 196 bytes
File Modification Date/Time     : 2015:03:23 17:56:49+01:00
File Access Date/Time           : 2015:03:23 17:56:17+01:00
File Creation Date/Time         : 2015:03:23 17:56:17+01:00
File Permissions                : rw-rw-rw-
Error                           : Unknown file type
« Last Edit: March 23, 2015, 05:58:05 PM by monochrome »

Mario

  • IMatch Developer
  • Administrator
  • *****
  • Posts: 30082
Re: Metadata Files (RDF)
« Reply #7 on: March 23, 2015, 06:25:42 PM »
IMatch does not process XML files with ExifTool anyway, because XML is not listed in the list of supported extensions

exiftool -listf

which is used by IMatch to tell if a file can be processed by ExifTool.


And we're talking about arbitrary files here, not a file which you copied down from Wikipedia and which just happens to be a XMP file. ExifTool is able to detect the names and knows the RDF namespace. What I'm talking about is your feature request to process generic XML files, which not follow any RDF syntax or being just XMP files in disguise.

Why don't you just write a script which parses your XML file, understands what it contains, and then puts the data somewhere, e.g. in IMatch attributes? Or rename the file to XMP, put a one pixel image next to it with the same name, and let IMatch do the work automatically.

monochrome

  • Full Member
  • **
  • Posts: 149
Re: Metadata Files (RDF)
« Reply #8 on: March 23, 2015, 06:48:23 PM »
IMatch does not process XML files with ExifTool anyway, because XML is not listed in the list of supported extensions

exiftool -listf

which is used by IMatch to tell if a file can be processed by ExifTool.

Thanks!

Why don't you just write a script which parses your XML file, understands what it contains, and then puts the data somewhere, e.g. in IMatch attributes? Or rename the file to XMP, put a one pixel image next to it with the same name, and let IMatch do the work automatically.

What I did was rename it to .rdf.xhtml. Same content, but now it imports just as I would expect it to.

Mario

  • IMatch Developer
  • Administrator
  • *****
  • Posts: 30082
Re: Metadata Files (RDF)
« Reply #9 on: March 23, 2015, 07:24:54 PM »
You used a file extension which is reported as "supported for read" by ExifTool. IMatch this routes the file to ExifTool and puts whatever ExifTool returns into the database. Since your file happens to contain a valid XMP RDF record, the data is imported correctly. I have no idea (and won't test) what happens if the file is not valid RDF or only partially valid. Do this at your own risk.