Skip to content

Commit 3097092

Browse files
committed
doc fixes
1 parent 850e8f6 commit 3097092

4 files changed

Lines changed: 45 additions & 10 deletions

File tree

readme.md

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,35 @@
11
# expkg-zone58.image.metadata
22
An XQuery library to extract image metadata as XML using the
33
[Drew Noakes library](http://drewnoakes.com/code/exif/)
4-
The output xml format matches the o/p of the [Xmlcalabash](http://xmlcalabash.com/) metadata extension.
5-
````
4+
The output XML format matches the o/p of the [Xmlcalabash](http://xmlcalabash.com/) metadata extension.
5+
```
6+
import module namespace imgmeta = "expkg-zone58:image.metadata" ;
7+
8+
declare variable $pic1:=resolve-uri("simple.jpg");
9+
imgmeta:read($pic1)
610
<metadata>
7-
<tag name=".." dir=".." type="..">value</tag>
8-
<tag ..
9-
</metadata>
11+
<tag name="Compression Type" dir="JPEG" type="0xfffffffd">Baseline</tag>
12+
<tag name="Data Precision" dir="JPEG" type="0x0000">8 bits</tag>
13+
<tag name="Image Height" dir="JPEG" type="0x0001">600 pixels</tag>
14+
<tag name="Image Width" dir="JPEG" type="0x0003">800 pixels</tag>
15+
<tag name="Number of Components" dir="JPEG" type="0x0005">3</tag>
16+
<tag name="Component 1" dir="JPEG" type="0x0006">Y component: Quantization table 0, Sampling factors 2 horiz/2 vert</tag>
17+
<tag name="Component 2" dir="JPEG" type="0x0007">Cb component: Quantization table 1, Sampling factors 1 horiz/1 vert</tag>
18+
<tag name="Component 3" dir="JPEG" type="0x0008">Cr component: Quantization table 1, Sampling factors 1 horiz/1 vert</tag>
19+
<tag name="JPEG Comment" dir="JpegComment" type="0x0000">AppleMark
20+
</tag>
21+
<tag name="Make" dir="Exif IFD0" type="0x010f">Canon</tag>
22+
<tag name="Model" dir="Exif IFD0" type="0x0110">Canon PowerShot S330</tag>
23+
<tag name="Orientation" dir="Exif IFD0" type="0x0112">Top, left side (Horizontal / normal)</tag>
24+
<tag name="X Resolution" dir="Exif IFD0" type="0x011a">180 dots per inch</tag>
25+
<tag name="Y Resolution" dir="Exif IFD0" type="0x011b">180 dots per inch</tag>
26+
<tag name="Resolution Unit" dir="Exif IFD0" type="0x0128">Inch</tag>
27+
<tag name="Software" dir="Exif IFD0" type="0x0131">QuickTime 6.0.2</tag>
28+
<tag name="Date/Time" dir="Exif IFD0" type="0x0132">2002-11-18T22:46:09</tag>
29+
<tag name="Host Computer" dir="Exif IFD0" type="0x013c">Mac OS X 10.2.2</tag>
30+
..
1031
````
11-
BaseX 8.2.1+ required.
32+
1233
1334
# Usage
1435
````

src/main/content/metadata-extractor.xqm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ declare function imgmeta:read($path as xs:string) as element(metadata)
3434
try {
3535
<metadata>{imgmeta:tags($path)}</metadata>
3636
} catch * {
37-
<metadata error="{$err:description}"/>
37+
<metadata error="{$err:code}">{$err:description}</metadata>
3838
}
3939
};
4040

@@ -193,6 +193,6 @@ declare function imgmeta:core($metadata as element(metadata)) as element()*
193193
if($d3 castable as xs:dateTime) then <datedigitized>{$d3/fn:string()}</datedigitized> else (),
194194
if($c) then <caption>{$c/fn:string()}</caption> else (),
195195
if($m) then <model>{$m/fn:string()}</model> else (),
196-
if($w and $h) then (<width>{$w}</width>,<height>{$h}</height>) else ()
196+
if($w and $h) then (<width>{$w}</width>,<height>{$h}</height>) else ()
197197
)
198198
};

src/test/gui-test.xq

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
:)
44

55
import module namespace metadata = "expkg-zone58:image.metadata" at "../main/content/metadata-extractor.xqm";
6-
declare namespace URL="java:java.net.URL";
6+
77

88
declare variable $pic1:=resolve-uri("simple.jpg");
99

src/test/test.xqm

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,18 @@ declare
1414
let $meta:=metadata:read($test:pic1)
1515
return unit:assert($meta/tag)
1616
};
17-
17+
18+
(:~ we get core info :)
19+
declare
20+
%unit:test
21+
function test:core() {
22+
let $meta:=metadata:read($test:pic1)
23+
return unit:assert(metadata:core($meta))
24+
};
25+
(:~ we get no keyword info :)
26+
declare
27+
%unit:test
28+
function test:keywords() {
29+
let $meta:=metadata:read($test:pic1)
30+
return unit:assert(metadata:keywords($meta)=>fn:empty())
31+
};

0 commit comments

Comments
 (0)