mirror of
https://github.com/openseadragon/openseadragon.git
synced 2025-01-19 17:21:50 +03:00
finished initial development of iiif info xml and json support, added example to site
This commit is contained in:
parent
3f20018c75
commit
aecf576c06
@ -6,7 +6,7 @@
|
||||
PROJECT: openseadragon
|
||||
BUILD_MAJOR: 0
|
||||
BUILD_MINOR: 9
|
||||
BUILD_ID: 102
|
||||
BUILD_ID: 107
|
||||
BUILD: ${PROJECT}.${BUILD_MAJOR}.${BUILD_MINOR}.${BUILD_ID}
|
||||
VERSION: ${BUILD_MAJOR}.${BUILD_MINOR}.${BUILD_ID}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*globals OpenSeadragon */
|
||||
|
||||
/**
|
||||
* @version OpenSeadragon 0.9.102
|
||||
* @version OpenSeadragon 0.9.107
|
||||
*
|
||||
* @fileOverview
|
||||
* <h2>
|
||||
@ -5624,7 +5624,7 @@ function processResponse( xhr ){
|
||||
data = xhr.responseText;
|
||||
}
|
||||
}else if( responseText.match(/\s*[\{\[].*/) ){
|
||||
data = eval( responseText );
|
||||
data = eval( '('+responseText+')' );
|
||||
}else{
|
||||
data = responseText;
|
||||
}
|
||||
@ -6071,7 +6071,7 @@ $.extend( $.IIIFTileSource.prototype, $.TileSource.prototype, {
|
||||
|
||||
if( !$.isPlainObject(data) ){
|
||||
|
||||
options = configureFromXML( this, data );
|
||||
options = configureFromXml( this, data );
|
||||
|
||||
}else{
|
||||
|
||||
@ -6201,50 +6201,13 @@ function configureFromXml( tileSource, xmlDoc ){
|
||||
|
||||
try {
|
||||
|
||||
|
||||
configuration = {
|
||||
"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" ]
|
||||
"ns": root.namespaceURI
|
||||
};
|
||||
|
||||
scale_factors = root.getElement('scale_factors');
|
||||
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
|
||||
);
|
||||
}
|
||||
}
|
||||
parseXML( root, configuration );
|
||||
|
||||
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 );
|
||||
|
||||
@ -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
|
||||
* @inner
|
||||
@ -6278,6 +6270,12 @@ function configureFromXml( tileSource, xmlDoc ){
|
||||
}
|
||||
*/
|
||||
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;
|
||||
};
|
||||
|
||||
|
@ -81,7 +81,7 @@ $.extend( $.IIIFTileSource.prototype, $.TileSource.prototype, {
|
||||
|
||||
if( !$.isPlainObject(data) ){
|
||||
|
||||
options = configureFromXML( this, data );
|
||||
options = configureFromXml( this, data );
|
||||
|
||||
}else{
|
||||
|
||||
@ -211,50 +211,13 @@ function configureFromXml( tileSource, xmlDoc ){
|
||||
|
||||
try {
|
||||
|
||||
|
||||
configuration = {
|
||||
"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" ]
|
||||
"ns": root.namespaceURI
|
||||
};
|
||||
|
||||
scale_factors = root.getElement('scale_factors');
|
||||
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
|
||||
);
|
||||
}
|
||||
}
|
||||
parseXML( root, configuration );
|
||||
|
||||
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 );
|
||||
|
||||
@ -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
|
||||
* @inner
|
||||
@ -288,6 +280,12 @@ function configureFromXml( tileSource, xmlDoc ){
|
||||
}
|
||||
*/
|
||||
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;
|
||||
};
|
||||
|
||||
|
@ -372,7 +372,7 @@ function processResponse( xhr ){
|
||||
data = xhr.responseText;
|
||||
}
|
||||
}else if( responseText.match(/\s*[\{\[].*/) ){
|
||||
data = eval( responseText );
|
||||
data = eval( '('+responseText+')' );
|
||||
}else{
|
||||
data = responseText;
|
||||
}
|
||||
|
@ -53,7 +53,6 @@ OpenSeadragon({
|
||||
minZoomLevel: 1,
|
||||
defaultZoomLevel: 1,
|
||||
tileSources: [{
|
||||
"tilesUrl": "http://img.princeton.edu/loris",
|
||||
"identifier": "pudl0001/4609321/s42/00000001",
|
||||
"width": 2617,
|
||||
"height": 3600,
|
||||
@ -62,7 +61,8 @@ OpenSeadragon({
|
||||
"tile_height": 256,
|
||||
"formats": [ "jpg", "png" ],
|
||||
"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
|
||||
@ -80,7 +80,7 @@ OpenSeadragon({
|
||||
minZoomLevel: 1,
|
||||
defaultZoomLevel: 1,
|
||||
tileSources: [{
|
||||
"tilesUrl": "http://img.princeton.edu/loris",
|
||||
"image_host": "http://img.princeton.edu/loris",
|
||||
"identifier": "pudl0001/4609321/s42/00000001",
|
||||
"width": 2617,
|
||||
"height": 3600,
|
||||
@ -91,7 +91,7 @@ OpenSeadragon({
|
||||
"qualities": ["native", "bitonal", "grey", "color"],
|
||||
"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",
|
||||
"width": 2547,
|
||||
"height": 3600,
|
||||
@ -102,7 +102,7 @@ OpenSeadragon({
|
||||
"qualities": ["native", "bitonal", "grey", "color"],
|
||||
"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",
|
||||
"width": 2694,
|
||||
"height": 3600,
|
||||
@ -113,7 +113,7 @@ OpenSeadragon({
|
||||
"qualities": ["native", "bitonal", "grey", "color"],
|
||||
"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",
|
||||
"width": 2717,
|
||||
"height": 3600,
|
||||
@ -124,7 +124,7 @@ OpenSeadragon({
|
||||
"qualities": ["native", "bitonal", "grey", "color"],
|
||||
"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",
|
||||
"width": 2694,
|
||||
"height": 3600,
|
||||
@ -135,7 +135,7 @@ OpenSeadragon({
|
||||
"qualities": ["native", "bitonal", "grey", "color"],
|
||||
"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",
|
||||
"width": 2717,
|
||||
"height": 3600,
|
||||
@ -146,7 +146,7 @@ OpenSeadragon({
|
||||
"qualities": ["native", "bitonal", "grey", "color"],
|
||||
"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",
|
||||
"width": 2694,
|
||||
"height": 3600,
|
||||
@ -160,3 +160,90 @@ OpenSeadragon({
|
||||
});
|
||||
</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>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<info xmlns="http://library.stanford.edu/iiif/image-api/ns/">
|
||||
<identifier>pudl0001/4609321/s42/00000004</identifier>
|
||||
<width>2717</width>
|
||||
<height>3600</height>
|
||||
<scale_factors>
|
||||
<scale_factor>1</scale_factor>
|
||||
<scale_factor>2</scale_factor>
|
||||
<scale_factor>3</scale_factor>
|
||||
<scale_factor>4</scale_factor>
|
||||
<scale_factor>5</scale_factor>
|
||||
</scale_factors>
|
||||
<tile_width>256</tile_width>
|
||||
<tile_height>256</tile_height>
|
||||
<formats>
|
||||
<format>jpg</format>
|
||||
<format>png</format>
|
||||
</formats>
|
||||
<qualities>
|
||||
<quality>native</quality>
|
||||
<quality>bitonal</quality>
|
||||
<quality>grey</quality>
|
||||
<quality>color</quality>
|
||||
</qualities>
|
||||
<profile>http://library.stanford.edu/iiif/image-api/compliance.html#level1</profile>
|
||||
<image_host>http://img.princeton.edu/loris</image_host>
|
||||
</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>
|
||||
|
Loading…
x
Reference in New Issue
Block a user