finished initial development of iiif info xml and json support, added example to site

This commit is contained in:
thatcher 2013-02-09 15:58:43 -05:00
parent 3f20018c75
commit aecf576c06
5 changed files with 178 additions and 95 deletions

View File

@ -6,7 +6,7 @@
PROJECT: openseadragon PROJECT: openseadragon
BUILD_MAJOR: 0 BUILD_MAJOR: 0
BUILD_MINOR: 9 BUILD_MINOR: 9
BUILD_ID: 102 BUILD_ID: 107
BUILD: ${PROJECT}.${BUILD_MAJOR}.${BUILD_MINOR}.${BUILD_ID} BUILD: ${PROJECT}.${BUILD_MAJOR}.${BUILD_MINOR}.${BUILD_ID}
VERSION: ${BUILD_MAJOR}.${BUILD_MINOR}.${BUILD_ID} VERSION: ${BUILD_MAJOR}.${BUILD_MINOR}.${BUILD_ID}

View File

@ -1,7 +1,7 @@
/*globals OpenSeadragon */ /*globals OpenSeadragon */
/** /**
* @version OpenSeadragon 0.9.102 * @version OpenSeadragon 0.9.107
* *
* @fileOverview * @fileOverview
* <h2> * <h2>
@ -5624,7 +5624,7 @@ function processResponse( xhr ){
data = xhr.responseText; data = xhr.responseText;
} }
}else if( responseText.match(/\s*[\{\[].*/) ){ }else if( responseText.match(/\s*[\{\[].*/) ){
data = eval( responseText ); data = eval( '('+responseText+')' );
}else{ }else{
data = responseText; data = responseText;
} }
@ -6071,7 +6071,7 @@ $.extend( $.IIIFTileSource.prototype, $.TileSource.prototype, {
if( !$.isPlainObject(data) ){ if( !$.isPlainObject(data) ){
options = configureFromXML( this, data ); options = configureFromXml( this, data );
}else{ }else{
@ -6201,50 +6201,13 @@ function configureFromXml( tileSource, xmlDoc ){
try { try {
configuration = { configuration = {
"ns": root.namespaceURI, "ns": root.namespaceURI
"identifier": root.getElement('identifier').innerHTML,
"width": root.getElement('width').innerHTML,
"height": root.getElement('height').innerHTML,
"scale_factors": null,
"tile_width": root.getElement('tile_width').innerHTML,
"tile_height": root.getElement('tile_height').innerHTML,
"formats": [ "jpg", "png" ],
"quality": [ "native", "grey" ]
}; };
scale_factors = root.getElement('scale_factors'); parseXML( root, configuration );
if( scale_factors ){
scale_factors = scale_factors.getElementsByTagName('scale_factor');
configuration.scale_factors = [];
for( i = 0; i < scale_factors.length; i++ ){
configuration.scale_factors.push(
scale_factors[ i ].innerHTML
);
}
}
formats = root.getElement('formats');
if( formats ){
formats = formats.getElementsByTagName('format');
configuration.formats = [];
for( i = 0; i < formats.length; i++ ){
configuration.formats.push(
formats[ i ].innerHTML
);
}
}
qualities = root.getElement('qualities');
if( qualities ){
qualities = formats.getElementsByTagName('quality');
configuration.quality = [];
for( i = 0; i < qualities.length; i++ ){
configuration.quality.push(
qualities[ i ].innerHTML
);
}
}
return configureFromObject( tileSource, configuration ); return configureFromObject( tileSource, configuration );
@ -6260,6 +6223,35 @@ function configureFromXml( tileSource, xmlDoc ){
}; };
/**
* @private
* @inner
* @function
*/
function parseXML( node, configuration, property ){
var i,
value;
if( node.nodeType == 3 && property ){//text node
value = node.nodeValue.trim();
if( value.match(/^\d*$/)){
value = Number( value );
}
if( !configuration[ property ] ){
configuration[ property ] = value;
}else{
if( !$.isArray( configuration[ property ] ) ){
configuration[ property ] = [ configuration[ property ] ];
}
configuration[ property ].push( value );
}
} else if( node.nodeType == 1 ){
for( i = 0; i < node.childNodes.length; i++ ){
parseXML( node.childNodes[ i ], configuration, node.nodeName );
}
}
}
/** /**
* @private * @private
* @inner * @inner
@ -6278,6 +6270,12 @@ function configureFromXml( tileSource, xmlDoc ){
} }
*/ */
function configureFromObject( tileSource, configuration ){ function configureFromObject( tileSource, configuration ){
//the image_host property is not part of the iiif standard but is included here to
//allow the info.json and info.xml specify a different server to load the
//images from so we can test the implementation.
if( configuration.image_host ){
configuration.tilesUrl = configuration.image_host;
}
return configuration; return configuration;
}; };

View File

@ -81,7 +81,7 @@ $.extend( $.IIIFTileSource.prototype, $.TileSource.prototype, {
if( !$.isPlainObject(data) ){ if( !$.isPlainObject(data) ){
options = configureFromXML( this, data ); options = configureFromXml( this, data );
}else{ }else{
@ -211,50 +211,13 @@ function configureFromXml( tileSource, xmlDoc ){
try { try {
configuration = { configuration = {
"ns": root.namespaceURI, "ns": root.namespaceURI
"identifier": root.getElement('identifier').innerHTML,
"width": root.getElement('width').innerHTML,
"height": root.getElement('height').innerHTML,
"scale_factors": null,
"tile_width": root.getElement('tile_width').innerHTML,
"tile_height": root.getElement('tile_height').innerHTML,
"formats": [ "jpg", "png" ],
"quality": [ "native", "grey" ]
}; };
scale_factors = root.getElement('scale_factors'); parseXML( root, configuration );
if( scale_factors ){
scale_factors = scale_factors.getElementsByTagName('scale_factor');
configuration.scale_factors = [];
for( i = 0; i < scale_factors.length; i++ ){
configuration.scale_factors.push(
scale_factors[ i ].innerHTML
);
}
}
formats = root.getElement('formats');
if( formats ){
formats = formats.getElementsByTagName('format');
configuration.formats = [];
for( i = 0; i < formats.length; i++ ){
configuration.formats.push(
formats[ i ].innerHTML
);
}
}
qualities = root.getElement('qualities');
if( qualities ){
qualities = formats.getElementsByTagName('quality');
configuration.quality = [];
for( i = 0; i < qualities.length; i++ ){
configuration.quality.push(
qualities[ i ].innerHTML
);
}
}
return configureFromObject( tileSource, configuration ); return configureFromObject( tileSource, configuration );
@ -270,6 +233,35 @@ function configureFromXml( tileSource, xmlDoc ){
}; };
/**
* @private
* @inner
* @function
*/
function parseXML( node, configuration, property ){
var i,
value;
if( node.nodeType == 3 && property ){//text node
value = node.nodeValue.trim();
if( value.match(/^\d*$/)){
value = Number( value );
}
if( !configuration[ property ] ){
configuration[ property ] = value;
}else{
if( !$.isArray( configuration[ property ] ) ){
configuration[ property ] = [ configuration[ property ] ];
}
configuration[ property ].push( value );
}
} else if( node.nodeType == 1 ){
for( i = 0; i < node.childNodes.length; i++ ){
parseXML( node.childNodes[ i ], configuration, node.nodeName );
}
}
}
/** /**
* @private * @private
* @inner * @inner
@ -288,6 +280,12 @@ function configureFromXml( tileSource, xmlDoc ){
} }
*/ */
function configureFromObject( tileSource, configuration ){ function configureFromObject( tileSource, configuration ){
//the image_host property is not part of the iiif standard but is included here to
//allow the info.json and info.xml specify a different server to load the
//images from so we can test the implementation.
if( configuration.image_host ){
configuration.tilesUrl = configuration.image_host;
}
return configuration; return configuration;
}; };

View File

@ -372,7 +372,7 @@ function processResponse( xhr ){
data = xhr.responseText; data = xhr.responseText;
} }
}else if( responseText.match(/\s*[\{\[].*/) ){ }else if( responseText.match(/\s*[\{\[].*/) ){
data = eval( responseText ); data = eval( '('+responseText+')' );
}else{ }else{
data = responseText; data = responseText;
} }

View File

@ -53,7 +53,6 @@ OpenSeadragon({
minZoomLevel: 1, minZoomLevel: 1,
defaultZoomLevel: 1, defaultZoomLevel: 1,
tileSources: [{ tileSources: [{
"tilesUrl": "http://img.princeton.edu/loris",
"identifier": "pudl0001/4609321/s42/00000001", "identifier": "pudl0001/4609321/s42/00000001",
"width": 2617, "width": 2617,
"height": 3600, "height": 3600,
@ -62,7 +61,8 @@ OpenSeadragon({
"tile_height": 256, "tile_height": 256,
"formats": [ "jpg", "png" ], "formats": [ "jpg", "png" ],
"qualities": ["native", "bitonal", "grey", "color"], "qualities": ["native", "bitonal", "grey", "color"],
"profile": "http://library.stanford.edu/iiif/image-api/compliance.html#level1" "profile": "http://library.stanford.edu/iiif/image-api/compliance.html#level1",
"image_host": "http://img.princeton.edu/loris"
}...,{ }...,{
...//more tile sources ...//more tile sources
@ -80,7 +80,7 @@ OpenSeadragon({
minZoomLevel: 1, minZoomLevel: 1,
defaultZoomLevel: 1, defaultZoomLevel: 1,
tileSources: [{ tileSources: [{
"tilesUrl": "http://img.princeton.edu/loris", "image_host": "http://img.princeton.edu/loris",
"identifier": "pudl0001/4609321/s42/00000001", "identifier": "pudl0001/4609321/s42/00000001",
"width": 2617, "width": 2617,
"height": 3600, "height": 3600,
@ -91,7 +91,7 @@ OpenSeadragon({
"qualities": ["native", "bitonal", "grey", "color"], "qualities": ["native", "bitonal", "grey", "color"],
"profile": "http://library.stanford.edu/iiif/image-api/compliance.html#level1" "profile": "http://library.stanford.edu/iiif/image-api/compliance.html#level1"
},{ },{
"tilesUrl": "http://img.princeton.edu/loris", "image_host": "http://img.princeton.edu/loris",
"identifier": "pudl0001/4609321/s42/00000002", "identifier": "pudl0001/4609321/s42/00000002",
"width": 2547, "width": 2547,
"height": 3600, "height": 3600,
@ -102,7 +102,7 @@ OpenSeadragon({
"qualities": ["native", "bitonal", "grey", "color"], "qualities": ["native", "bitonal", "grey", "color"],
"profile": "http://library.stanford.edu/iiif/image-api/compliance.html#level1" "profile": "http://library.stanford.edu/iiif/image-api/compliance.html#level1"
},{ },{
"tilesUrl": "http://img.princeton.edu/loris", "image_host": "http://img.princeton.edu/loris",
"identifier": "pudl0001/4609321/s42/00000003", "identifier": "pudl0001/4609321/s42/00000003",
"width": 2694, "width": 2694,
"height": 3600, "height": 3600,
@ -113,7 +113,7 @@ OpenSeadragon({
"qualities": ["native", "bitonal", "grey", "color"], "qualities": ["native", "bitonal", "grey", "color"],
"profile": "http://library.stanford.edu/iiif/image-api/compliance.html#level1" "profile": "http://library.stanford.edu/iiif/image-api/compliance.html#level1"
},{ },{
"tilesUrl": "http://img.princeton.edu/loris", "image_host": "http://img.princeton.edu/loris",
"identifier": "pudl0001/4609321/s42/00000004", "identifier": "pudl0001/4609321/s42/00000004",
"width": 2717, "width": 2717,
"height": 3600, "height": 3600,
@ -124,7 +124,7 @@ OpenSeadragon({
"qualities": ["native", "bitonal", "grey", "color"], "qualities": ["native", "bitonal", "grey", "color"],
"profile": "http://library.stanford.edu/iiif/image-api/compliance.html#level1" "profile": "http://library.stanford.edu/iiif/image-api/compliance.html#level1"
},{ },{
"tilesUrl": "http://img.princeton.edu/loris", "image_host": "http://img.princeton.edu/loris",
"identifier": "pudl0001/4609321/s42/00000005", "identifier": "pudl0001/4609321/s42/00000005",
"width": 2694, "width": 2694,
"height": 3600, "height": 3600,
@ -135,7 +135,7 @@ OpenSeadragon({
"qualities": ["native", "bitonal", "grey", "color"], "qualities": ["native", "bitonal", "grey", "color"],
"profile": "http://library.stanford.edu/iiif/image-api/compliance.html#level1" "profile": "http://library.stanford.edu/iiif/image-api/compliance.html#level1"
},{ },{
"tilesUrl": "http://img.princeton.edu/loris", "image_host": "http://img.princeton.edu/loris",
"identifier": "pudl0001/4609321/s42/00000006", "identifier": "pudl0001/4609321/s42/00000006",
"width": 2717, "width": 2717,
"height": 3600, "height": 3600,
@ -146,7 +146,7 @@ OpenSeadragon({
"qualities": ["native", "bitonal", "grey", "color"], "qualities": ["native", "bitonal", "grey", "color"],
"profile": "http://library.stanford.edu/iiif/image-api/compliance.html#level1" "profile": "http://library.stanford.edu/iiif/image-api/compliance.html#level1"
},{ },{
"tilesUrl": "http://img.princeton.edu/loris", "image_host": "http://img.princeton.edu/loris",
"identifier": "pudl0001/4609321/s42/00000007", "identifier": "pudl0001/4609321/s42/00000007",
"width": 2694, "width": 2694,
"height": 3600, "height": 3600,
@ -160,3 +160,90 @@ OpenSeadragon({
}); });
</script> </script>
<div class="description">
<h3>XMLHTTPRequest for IIIF info.xml or info.json</h3>
<p>
The following example info.json and info.xml documents are non-normative and include
a property <strong>image_host</strong> which allows the info.json and info.xml
to be hosted from a different server than the images are served from.
</p>
</div>
<div class="demoarea">
<div class="demoheading">
Example XMLHTTPRequest for IIIF info ( XML or JSON )
</div>
<div id="example-xmlhttprequest-for-info-xml"
class="openseadragon">
<script type="text/javascript">
OpenSeadragon({
id: "example-xmlhttprequest-for-info-xml",
prefixUrl: "/openseadragon/images/",
tileSources: [
"/openseadragon/examples/images/loris/pudl0001/4609321/s42/00000003/info.json",
"/openseadragon/examples/images/loris/pudl0001/4609321/s42/00000004/info.xml"
]
});
</script>
<noscript>
<p>Deep zoom is not available unless javascript is enabled.</p>
<img src='../images/highsmith/01967v.jpg'
height='600'/>
</noscript>
</div>
<p>
Below is a sample IIIF info file formatted as XML.
</p>
<pre>
&lt;?xml version="1.0" encoding="UTF-8"?>
&lt;info xmlns="http://library.stanford.edu/iiif/image-api/ns/">
&lt;identifier>pudl0001/4609321/s42/00000004&lt;/identifier>
&lt;width>2717&lt;/width>
&lt;height>3600&lt;/height>
&lt;scale_factors>
&lt;scale_factor>1&lt;/scale_factor>
&lt;scale_factor>2&lt;/scale_factor>
&lt;scale_factor>3&lt;/scale_factor>
&lt;scale_factor>4&lt;/scale_factor>
&lt;scale_factor>5&lt;/scale_factor>
&lt;/scale_factors>
&lt;tile_width>256&lt;/tile_width>
&lt;tile_height>256&lt;/tile_height>
&lt;formats>
&lt;format>jpg&lt;/format>
&lt;format>png&lt;/format>
&lt;/formats>
&lt;qualities>
&lt;quality>native&lt;/quality>
&lt;quality>bitonal&lt;/quality>
&lt;quality>grey&lt;/quality>
&lt;quality>color&lt;/quality>
&lt;/qualities>
&lt;profile>http://library.stanford.edu/iiif/image-api/compliance.html#level1&lt;/profile>
&lt;image_host>http://img.princeton.edu/loris&lt;/image_host>
&lt;/info></pre>
<p>
And the equivalent sample IIIF info file formatted as JSON.
</p>
<pre>
{
"identifier" : "pudl0001/4609321/s42/00000003",
"width": 2694,
"height": 3600,
"scale_factors" : [1, 2, 3, 4, 5],
"tile_width" : 256,
"tile_height" : 256,
"formats" : [ "jpg", "png" ],
"qualities" : ["native", "bitonal", "grey", "color"],
"profile" : "http://library.stanford.edu/iiif/image-api/compliance.html#level1",
"image_host": "http://img.princeton.edu/loris"
}</pre>
<pre>
OpenSeadragon({
...
tileSources: [
"/openseadragon/examples/images/loris/pudl0001/4609321/s42/00000003/info.json",
"/openseadragon/examples/images/loris/pudl0001/4609321/s42/00000004/info.xml"
],
...
});</pre>
</div>