Skip to content

Commit

Permalink
Merge pull request #62 from ruven/master
Browse files Browse the repository at this point in the history
Update to IIP layout in relight.js
  • Loading branch information
ponchio authored Oct 25, 2023
2 parents e2bd5f8 + d5703e7 commit b66632b
Show file tree
Hide file tree
Showing 5 changed files with 678 additions and 14 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Scale and bias will be applied to the texture coefficients (from [0, 1]) as:
* [Deepzoom](https://www.microsoft.com/silverlight/deep-zoom/)
* [Zoomify](http://www.zoomify.com/)
* [Google maps](https://developers.google.com/maps/)
* [IIP](http://iipimage.sourceforge.net/)
* [IIP](https://iipimage.sourceforge.io/)
* [IIIF](http://iiif.io)

[libvips](http://jcupitt.github.io/libvips/supported/current) can be used to [generate deepzoom, zoomify and google pyramidal formats](http://libvips.blogspot.com/2013/03/making-deepzoom-zoomify-and-google-maps.html), scripts can be found in the directory *test*.
Expand All @@ -92,7 +92,8 @@ Scale and bias will be applied to the texture coefficients (from [0, 1]) as:
Options:
* url: path to a directory containing the web format
* layout: deepzoom, zoomify, google, iip, iiif or image for the web format
* path: used for iip layout, absolute path of the dir.
* server: server URL for use with iip or iiif
* stack: true or false - whether image is an image stack (IIP only)
* light: initial light, array x, y, z.
* pos: initial view object { x: y: z:}
* border: for tiled formats amount of prefetching tiles arount the view (default 1)
Expand Down
21 changes: 14 additions & 7 deletions js/relight-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ Overlay enlarges the tiles but not the side on the border of the image (need to
Options:
gl: if provided will use an already created context
url: path of the directory where the json (and the images) resides
path: for iip absolute path of the same directory
url: path of the directory where the json (and the images) reside
stack: true or false - whether image is an image stack (IIP only)
server: server for IIP or IIIF layouts
layout: pick between image, deepzoom, google, iip, iiif, zoomify
visible: rendering active or not, (default: true)
light: initial light (default [0, 0, 1]
Expand Down Expand Up @@ -127,6 +128,10 @@ setUrl: function(url) {
t.waiting = 1;
if (t.layout == "webrtiviewer") {
t.get(url + '/info.xml', 'xml', function(d) { t.waiting--; t.loadWebRTIViewerInfo(d); });
} else if (t.layout == "iip" ) {
// info.json embedded in TIFF ImageDescription metadata tag
var url = t.server + "?FIF=" + t.url + ((t.stack===true) ? "" : "/plane_0.tif") + "&OBJ=xmp";
t.get(url, 'json', function(d) { t.waiting--; t.loadInfo(d); });
} else {
t.get(url + '/info.json', 'json', function(d) { t.waiting--; t.loadInfo(d); });
}
Expand Down Expand Up @@ -626,7 +631,9 @@ initTree: function() {
case "iip":
t.suffix = ".tif";
t.overlap = 0;
t.metaDataURL = t.server + "?FIF=" + t.path + "/" + t.img + t.suffix + "&obj=IIP,1.0&obj=Max-size&obj=Tile-size&obj=Resolution-number";

t.metaDataURL = t.server + "?FIF=" + ((t.stack===true) ? t.url : t.url + "/" + t.img + t.suffix) +
"&obj=Max-size&obj=Tile-size&obj=Resolution-number";

t.parseMetaData = function(response) {
var tmp = response.split( "Tile-size:" );
Expand All @@ -642,10 +649,12 @@ initTree: function() {

t.getTileURL = function(image, x, y, level) {
var prefix = image.substr(0, image.lastIndexOf("."));
var img = t.path + "/" + prefix + t.suffix;
var plane = parseInt(prefix.split('_')[1]);
var index = y*t.qbox[level][2] + x;
var ilevel = parseInt(t.nlevels - 1 - level);
return t.server+"?FIF=" + img + "&JTL=" + ilevel + "," + index;
var img = (t.stack===true) ? t.url + "&SDS=" + plane : t.url + "/" + prefix + t.suffix;
var url = t.server+"?FIF=" + img + "&JTL=" + ilevel + "," + index;
return url;
};
break;

Expand Down Expand Up @@ -1451,5 +1460,3 @@ neededBox: function(pos, border, canvas) {
}

};


Loading

0 comments on commit b66632b

Please sign in to comment.