Compare commits
8 Commits
9988fcebc1
...
6494b49d67
Author | SHA1 | Date | |
---|---|---|---|
|
6494b49d67 | ||
|
ddd375b378 | ||
|
1b777c9e62 | ||
|
d35c0a6385 | ||
|
86dabe624b | ||
|
7a97d524f8 | ||
|
820564dd3e | ||
|
6eeccb530b |
@ -51,8 +51,11 @@ $.IIIFTileSource = function( options ){
|
||||
|
||||
$.extend( true, this, options );
|
||||
|
||||
if ( !( this.height && this.width && this['@id'] ) ) {
|
||||
throw new Error( 'IIIF required parameters not provided.' );
|
||||
/* Normalizes v3-style 'id' keys to an "_id" internal property */
|
||||
this._id = this["@id"] || this["id"] || this['identifier'] || null;
|
||||
|
||||
if ( !( this.height && this.width && this._id) ) {
|
||||
throw new Error( 'IIIF required parameters (width, height, or id) not provided.' );
|
||||
}
|
||||
|
||||
options.tileSizePerScaleFactor = {};
|
||||
@ -147,7 +150,7 @@ $.extend( $.IIIFTileSource.prototype, $.TileSource.prototype, /** @lends OpenSea
|
||||
* this tile source.
|
||||
* @function
|
||||
* @param {Object|Array} data
|
||||
* @param {String} optional - url
|
||||
* @param {String} [url] - url
|
||||
*/
|
||||
|
||||
supports: function( data, url ) {
|
||||
@ -180,23 +183,29 @@ $.extend( $.IIIFTileSource.prototype, $.TileSource.prototype, /** @lends OpenSea
|
||||
},
|
||||
|
||||
/**
|
||||
* A static function used to prepare an incoming IIIF Image API info.json
|
||||
* response for processing by the tile handler. Normalizes data for all
|
||||
* versions of IIIF (1.0, 1.1, 2.x, 3.x) and returns a data object that
|
||||
* may be passed to the IIIFTileSource.
|
||||
*
|
||||
* @function
|
||||
* @static
|
||||
* @param {Object} data - the raw configuration
|
||||
* @param {String} url - the url configuration was retrieved from
|
||||
* @param {String} postData - HTTP POST data in k=v&k2=v2... form or null
|
||||
* @example <caption>IIIF 1.1 Info Looks like this</caption>
|
||||
* @return {Object} A normalized IIIF data object
|
||||
* @example <caption>IIIF 2.x Info Looks like this</caption>
|
||||
* {
|
||||
* "@context" : "http://library.stanford.edu/iiif/image-api/1.1/context.json",
|
||||
* "@id" : "http://iiif.example.com/prefix/1E34750D-38DB-4825-A38A-B60A345E591C",
|
||||
* "width" : 6000,
|
||||
* "height" : 4000,
|
||||
* "scale_factors" : [ 1, 2, 4 ],
|
||||
* "tile_width" : 1024,
|
||||
* "tile_height" : 1024,
|
||||
* "formats" : [ "jpg", "png" ],
|
||||
* "qualities" : [ "native", "grey" ],
|
||||
* "profile" : "http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level0"
|
||||
* "@context": "http://iiif.io/api/image/2/context.json",
|
||||
* "@id": "http://iiif.example.com/prefix/1E34750D-38DB-4825-A38A-B60A345E591C",
|
||||
* "protocol": "http://iiif.io/api/image",
|
||||
* "height": 1024,
|
||||
* "width": 775,
|
||||
* "tiles" : [{"width":256, "scaleFactors":[1,2,4,8]}],
|
||||
* "profile": ["http://iiif.io/api/image/2/level1.json", {
|
||||
* "qualities": [ "native", "bitonal", "grey", "color" ],
|
||||
* "formats": [ "jpg", "png", "gif" ]
|
||||
* }]
|
||||
* }
|
||||
*/
|
||||
configure: function( data, url, postData ){
|
||||
@ -204,13 +213,13 @@ $.extend( $.IIIFTileSource.prototype, $.TileSource.prototype, /** @lends OpenSea
|
||||
if ( !$.isPlainObject(data) ) {
|
||||
var options = configureFromXml10( data );
|
||||
options['@context'] = "http://iiif.io/api/image/1.0/context.json";
|
||||
options['@id'] = url.replace('/info.xml', '');
|
||||
options["@id"] = url.replace('/info.xml', '');
|
||||
options.version = 1;
|
||||
return options;
|
||||
} else {
|
||||
if ( !data['@context'] ) {
|
||||
data['@context'] = 'http://iiif.io/api/image/1.0/context.json';
|
||||
data['@id'] = url.replace('/info.json', '');
|
||||
data["@id"] = url.replace('/info.json', '');
|
||||
data.version = 1;
|
||||
} else {
|
||||
var context = data['@context'];
|
||||
@ -239,10 +248,8 @@ $.extend( $.IIIFTileSource.prototype, $.TileSource.prototype, /** @lends OpenSea
|
||||
$.console.error('Data has a @context property which contains no known IIIF context URI.');
|
||||
}
|
||||
}
|
||||
if ( !data['@id'] && data['id'] ) {
|
||||
data['@id'] = data['id'];
|
||||
}
|
||||
if(data.preferredFormats) {
|
||||
|
||||
if (data.preferredFormats) {
|
||||
for (var f = 0; f < data.preferredFormats.length; f++ ) {
|
||||
if ( OpenSeadragon.imageFormatSupported(data.preferredFormats[f]) ) {
|
||||
data.tileFormat = data.preferredFormats[f];
|
||||
@ -431,7 +438,7 @@ $.extend( $.IIIFTileSource.prototype, $.TileSource.prototype, /** @lends OpenSea
|
||||
iiifSize = iiifSizeW + ",";
|
||||
}
|
||||
}
|
||||
uri = [ this['@id'], iiifRegion, iiifSize, IIIF_ROTATION, iiifQuality ].join( '/' );
|
||||
uri = [ this._id, iiifRegion, iiifSize, IIIF_ROTATION, iiifQuality ].join( '/' );
|
||||
|
||||
return uri;
|
||||
},
|
||||
@ -482,7 +489,7 @@ $.extend( $.IIIFTileSource.prototype, $.TileSource.prototype, /** @lends OpenSea
|
||||
var levels = [];
|
||||
for(var i = 0; i < options.sizes.length; i++) {
|
||||
levels.push({
|
||||
url: options['@id'] + '/full/' + options.sizes[i].width + ',' +
|
||||
url: options._id + '/full/' + options.sizes[i].width + ',' +
|
||||
(options.version === 3 ? options.sizes[i].height : '') +
|
||||
'/0/default.' + options.tileFormat,
|
||||
width: options.sizes[i].width,
|
||||
|
BIN
test/data/iiif_3_0_sizes/full/1600,1164/0/default.jpg
Normal file
After Width: | Height: | Size: 208 KiB |
BIN
test/data/iiif_3_0_sizes/full/3200,2328/0/default.jpg
Normal file
After Width: | Height: | Size: 678 KiB |
BIN
test/data/iiif_3_0_sizes/full/400,291/0/default.jpg
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
test/data/iiif_3_0_sizes/full/6976,5074/0/default.jpg
Normal file
After Width: | Height: | Size: 1.8 MiB |
BIN
test/data/iiif_3_0_sizes/full/800,582/0/default.jpg
Normal file
After Width: | Height: | Size: 67 KiB |
15
test/data/iiif_3_0_sizes/info.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"@context": "http://iiif.io/api/image/3/context.json",
|
||||
"id": "http://localhost:8000/test/data/iiif_3_0_sizes",
|
||||
"protocol": "http://iiif.io/api/image",
|
||||
"width": 6976,
|
||||
"height": 5074,
|
||||
"profile": "level0",
|
||||
"sizes" : [
|
||||
{"width" : 400, "height" : 291},
|
||||
{"width" : 800, "height" : 582},
|
||||
{"width" : 1600, "height" : 1164},
|
||||
{"width" : 3200, "height": 2328},
|
||||
{"width" : 6976, "height": 5074}
|
||||
]
|
||||
}
|
BIN
test/data/iiif_3_0_tiled/0,0,256,256/256,256/0/default.jpg
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
test/data/iiif_3_0_tiled/0,0,512,512/256,256/0/default.jpg
Normal file
After Width: | Height: | Size: 32 KiB |
BIN
test/data/iiif_3_0_tiled/0,0,775,1024/194,256/0/default.jpg
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
test/data/iiif_3_0_tiled/0,256,256,256/256,256/0/default.jpg
Normal file
After Width: | Height: | Size: 27 KiB |
BIN
test/data/iiif_3_0_tiled/0,512,256,256/256,256/0/default.jpg
Normal file
After Width: | Height: | Size: 27 KiB |
BIN
test/data/iiif_3_0_tiled/0,512,512,512/256,256/0/default.jpg
Normal file
After Width: | Height: | Size: 27 KiB |
BIN
test/data/iiif_3_0_tiled/0,768,256,256/256,256/0/default.jpg
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
test/data/iiif_3_0_tiled/256,0,256,256/256,256/0/default.jpg
Normal file
After Width: | Height: | Size: 23 KiB |
BIN
test/data/iiif_3_0_tiled/256,256,256,256/256,256/0/default.jpg
Normal file
After Width: | Height: | Size: 36 KiB |
BIN
test/data/iiif_3_0_tiled/256,512,256,256/256,256/0/default.jpg
Normal file
After Width: | Height: | Size: 35 KiB |
BIN
test/data/iiif_3_0_tiled/256,768,256,256/256,256/0/default.jpg
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
test/data/iiif_3_0_tiled/512,0,256,256/256,256/0/default.jpg
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
test/data/iiif_3_0_tiled/512,0,263,512/132,256/0/default.jpg
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
test/data/iiif_3_0_tiled/512,256,256,256/256,256/0/default.jpg
Normal file
After Width: | Height: | Size: 20 KiB |
BIN
test/data/iiif_3_0_tiled/512,512,256,256/256,256/0/default.jpg
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
test/data/iiif_3_0_tiled/512,512,263,512/132,256/0/default.jpg
Normal file
After Width: | Height: | Size: 9.9 KiB |
BIN
test/data/iiif_3_0_tiled/512,768,256,256/256,256/0/default.jpg
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
test/data/iiif_3_0_tiled/768,0,7,256/7,256/0/default.jpg
Normal file
After Width: | Height: | Size: 717 B |
BIN
test/data/iiif_3_0_tiled/768,256,7,256/7,256/0/default.jpg
Normal file
After Width: | Height: | Size: 716 B |
BIN
test/data/iiif_3_0_tiled/768,512,7,256/7,256/0/default.jpg
Normal file
After Width: | Height: | Size: 717 B |
BIN
test/data/iiif_3_0_tiled/768,768,7,256/7,256/0/default.jpg
Normal file
After Width: | Height: | Size: 712 B |
BIN
test/data/iiif_3_0_tiled/full/1,/0/default.jpg
Normal file
After Width: | Height: | Size: 633 B |
BIN
test/data/iiif_3_0_tiled/full/13,/0/default.jpg
Normal file
After Width: | Height: | Size: 810 B |
BIN
test/data/iiif_3_0_tiled/full/2,/0/default.jpg
Normal file
After Width: | Height: | Size: 663 B |
BIN
test/data/iiif_3_0_tiled/full/25,/0/default.jpg
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
test/data/iiif_3_0_tiled/full/4,/0/default.jpg
Normal file
After Width: | Height: | Size: 675 B |
BIN
test/data/iiif_3_0_tiled/full/49,/0/default.jpg
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
test/data/iiif_3_0_tiled/full/7,/0/default.jpg
Normal file
After Width: | Height: | Size: 683 B |
BIN
test/data/iiif_3_0_tiled/full/97,/0/default.jpg
Normal file
After Width: | Height: | Size: 7.1 KiB |
11
test/data/iiif_3_0_tiled/info.json
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"@context": "http://iiif.io/api/image/3/context.json",
|
||||
"id": "http://localhost:8000/test/data/iiif_3_0_tiled",
|
||||
"protocol": "http://iiif.io/api/image",
|
||||
"height": 1024,
|
||||
"width": 775,
|
||||
"tiles" : [{"width":256, "scaleFactors":[1,2,4,8]}],
|
||||
"profile": "level2",
|
||||
"extraQualities": ["bitonal", "grey", "color"],
|
||||
"extraFormats": ["jpg", "png", "gif" ]
|
||||
}
|
BIN
test/data/iiif_3_0_tiled_sf1/0,0,256,256/256,256/0/default.jpg
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
test/data/iiif_3_0_tiled_sf1/0,256,256,256/256,256/0/default.jpg
Normal file
After Width: | Height: | Size: 27 KiB |
BIN
test/data/iiif_3_0_tiled_sf1/0,512,256,256/256,256/0/default.jpg
Normal file
After Width: | Height: | Size: 27 KiB |
BIN
test/data/iiif_3_0_tiled_sf1/0,768,256,256/256,256/0/default.jpg
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
test/data/iiif_3_0_tiled_sf1/256,0,256,256/256,256/0/default.jpg
Normal file
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 35 KiB |
After Width: | Height: | Size: 15 KiB |
BIN
test/data/iiif_3_0_tiled_sf1/512,0,256,256/256,256/0/default.jpg
Normal file
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 19 KiB |
After Width: | Height: | Size: 11 KiB |
BIN
test/data/iiif_3_0_tiled_sf1/768,0,7,256/7,256/0/default.jpg
Normal file
After Width: | Height: | Size: 717 B |
BIN
test/data/iiif_3_0_tiled_sf1/768,256,7,256/7,256/0/default.jpg
Normal file
After Width: | Height: | Size: 716 B |
BIN
test/data/iiif_3_0_tiled_sf1/768,512,7,256/7,256/0/default.jpg
Normal file
After Width: | Height: | Size: 717 B |
BIN
test/data/iiif_3_0_tiled_sf1/768,768,7,256/7,256/0/default.jpg
Normal file
After Width: | Height: | Size: 712 B |
11
test/data/iiif_3_0_tiled_sf1/info.json
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"@context": "http://iiif.io/api/image/3/context.json",
|
||||
"id": "http://localhost:8000/test/data/iiif_3_0_tiled_sf1",
|
||||
"protocol": "http://iiif.io/api/image",
|
||||
"height": 1024,
|
||||
"width": 775,
|
||||
"tiles" : [{"width": 256, "scaleFactors": [1]}],
|
||||
"profile": "level2",
|
||||
"extraQualities": ["bitonal", "grey", "color"],
|
||||
"extraFormats": ["jpg", "png", "gif" ]
|
||||
}
|
@ -151,6 +151,20 @@
|
||||
'}', assert);
|
||||
});
|
||||
|
||||
QUnit.test('IIIF 3.0 JSON', function(assert) {
|
||||
testOpenUrl('iiif_3_0_tiled/info.json', assert);
|
||||
});
|
||||
|
||||
// ----------
|
||||
QUnit.test('IIIF 3.0 JSON scaleFactors [1]', function(assert) {
|
||||
testOpenUrl('iiif_3_0_tiled_sf1/info.json', assert);
|
||||
});
|
||||
|
||||
// ----------
|
||||
QUnit.test('IIIF 3.0 JSON, sizes array only', function(assert) {
|
||||
testOpenUrl('iiif_3_0_sizes/info.json', assert);
|
||||
});
|
||||
|
||||
// ----------
|
||||
QUnit.test('ImageTileSource', function(assert) {
|
||||
testOpen({
|
||||
|
@ -143,7 +143,9 @@
|
||||
"profile": "level1"
|
||||
};
|
||||
|
||||
QUnit.test('IIIFTileSource.configure determins correct version', function(assert) {
|
||||
QUnit.module('IIIF');
|
||||
|
||||
QUnit.test('IIIFTileSource.configure determines correct version', function(assert) {
|
||||
var options1_0xml = configure(infoXml10level0);
|
||||
assert.ok(options1_0xml.version);
|
||||
assert.equal(options1_0xml.version, 1, 'Version is 1 for version 1.0 info.xml');
|
||||
|
@ -26,6 +26,7 @@
|
||||
<script src="/test/modules/basic.js"></script>
|
||||
<script src="/test/modules/strings.js"></script>
|
||||
<script src="/test/modules/formats.js"></script>
|
||||
<script src="/test/modules/iiif.js"></script>
|
||||
<script src="/test/modules/utils.js"></script>
|
||||
<script src="/test/modules/events.js"></script>
|
||||
<script src="/test/modules/units.js"></script>
|
||||
@ -46,7 +47,6 @@
|
||||
<script src="/test/modules/ajax-tiles.js"></script>
|
||||
<script src="/test/modules/ajax-post-data.js"></script>
|
||||
<script src="/test/modules/imageloader.js"></script>
|
||||
<script src="/test/modules/iiif.js"></script>
|
||||
<!--The navigator tests are the slowest (for now; hopefully they can be sped up)
|
||||
so we put them last. -->
|
||||
<script src="/test/modules/navigator.js"></script>
|
||||
|