Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| blocks:app-note:deepzoom [2021-08-27 20:45] – [A block example using multiple dzi source files] mattias | blocks:app-note:deepzoom [2026-02-19 07:34] (current) – Added note about the new Deep Zoom block type admin | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ======Deep Zoom====== | + | =====Deep Zoom===== |
| - | Work in Priogress | + | |
| - | Blocks has currently not any native feature for curating deep zoom imagery. | + | :!: **IMPORTANT**: |
| + | ---- | ||
| + | The term "deep zoom" refers to the ability of displaying extremely high resolution images in a way that allows you to zoom into the image using pinch and pan gestures on a touch screen. This can be used to show, for example, a large map where you can zoom in to read fine print or see other details. It's based on a [[https:// | ||
| - | ====Try | + | This application note shows how a Web Block can be used to present such deep zoom images. It's based on a small amount of custom html and an image that has been preprocessed using a command line program to create a pyramid representation. This is all embedded into the block itself, as a self contained unit that can be imported to any Blocks server |
| - | Download {{ : | + | |
| + | ====Using the deep zoom block==== | ||
| + | |||
| + | To try out a deep zoom image on your own Blocks server, do as follows: | ||
| + | |||
| + | * Download {{ : | ||
| + | * Import | ||
| + | * Drag the resulting | ||
| + | * Pinch (or use the scroll wheel) | ||
| {{: | {{: | ||
| - | If you rather try it out on on a visitor spot, you may want to {{ : | + | Here' |
| - | ====How does it work==== | + | ====Inside the deep zoom==== |
| + | The two blocks mentioned above bundles a custom web page with the pyramidal representation of the image. Normally, you wouldn' | ||
| - | This block has a custom component the is stored inside the example blocks folder. This makes it self contained and can be distributed via the editor. | ||
| - | Open the zip zile in finder/ | ||
| - | |||
| - | You should see something simular to this: | ||
| {{: | {{: | ||
| - | Where the files //Spec.pixi, Meta, | + | The //Spec.pixi// and //Meta, |
| {{: | {{: | ||
| - | //Index.html// | + | The //index.html// |
| - | //Openseadragon.min.js// is the js libary | + | Looking more closely at the files in the //custom// directory, you'll see an // |
| - | // | + | {{: |
| - | //Out// is where we find our deep zoom media. The media has been processed into a //dzi// package. | + | Inside the //out// folder, you' |
| - | This is a pyramid | + | |
| - | A dzi package has two components, a description file, in our example it is hr.dzi and a folder prefixed with the same name where all the processed images is stored. | + | In case you're interested in the inner workings of the web page used to show the deep zoom image, take a look in the //index.html// file: |
| - | {{:blocks: | + | |
| - | How to create such package is covered later in this article. | ||
| - | |||
| - | The code inside the // | ||
| < | < | ||
| < | < | ||
| <html lang=" | <html lang=" | ||
| - | < | + | |
| - | <meta charset=" | + | <meta charset=" |
| - | < | + | < |
| - | < | + | < |
| - | html, body { | + | html, body { |
| - | margin:0; | + | margin:0; |
| - | padding: 0; | + | padding: 0; |
| - | } | + | } |
| - | # | + | # |
| - | width: 1920px; height: 1080px; | + | width: 1920px; height: 1080px; |
| - | } | + | } |
| - | </ | + | </ |
| - | </ | + | </ |
| - | < | + | < |
| - | <div id=" | + | <div id=" |
| - | <script src=" | + | <script src=" |
| - | <script type=" | + | <script type=" |
| - | + | var viewer = OpenSeadragon({ | |
| - | | + | |
| id: " | id: " | ||
| prefixUrl: " | prefixUrl: " | ||
| tileSources: | tileSources: | ||
| - | showNavigationControl: | + | |
| - | }); | + | |
| - | + | | |
| - | </ | + | </ |
| - | </ | + | </ |
| </ | </ | ||
| </ | </ | ||
| - | At the top we got the usual HTML document header followed by a head element | + | Most of it is just standard |
| - | The size of the seadragon | + | The small amount |
| - | <code> | + | If you have access to the file system of your Blocks server (e.g., you're running Blocks locally on your laptop), you can locate these files under public/ |
| - | # | + | |
| - | width: 1920px; height: 1080px; | + | |
| - | } | + | |
| - | </code> | + | |
| - | The the html element where the viewer is displayed is here. | ||
| - | Finally we got the script part where the first line referenses | + | ====Preparing high resolution images for deep zoom==== |
| - | < | + | A Java-based program is used to preprocess for deep zoom use. This program requires a recent version of Java installed on your computer. If you're not sure if this is available, do as follows: |
| - | < | + | |
| - | <script type=" | + | |
| - | var viewer = OpenSeadragon({ | + | * Open a terminal window. |
| - | id: " | + | * Type //java -version// and press enter. |
| - | prefixUrl: " | + | |
| - | tileSources: | + | |
| - | showNavigationControl: | + | |
| - | }); | + | |
| - | </script> | + | If this command isn't recognized, you need to [[https://adoptopenjdk.net|download and install]] Java before proceeding. If a version number is shown, make sure it's version 8 or later. You should also make sure the JAVA_HOME enviroment variable is set on the computer (at least on windows). If it is not you cannot just type java in the terminal, you will have to use the full path to java everytime you use it. Use google to see how to do that. |
| - | </code> | + | |
| - | The full list of otions to experiment with is available | + | Then go ahead and {{: |
| + | Extract the // | ||
| + | Two script files are included, showing how to use the command line program; // | ||
| + | < | ||
| + | Be patient, it takes a minute or so. You will se this message in the terminal while the process is running: | ||
| + | < | ||
| + | To process another image, just copy the file to the same directory as the tool and change //hr.jpg// in the command to the name of your new file. The result will end up in the //out// directory, prefixed with the source image file name. Avoid using spaces or non-ASCII characters in the file name. | ||
| + | Copy the resulting file and folder from inside the //out// directory into your deep zoom block' | ||
| + | The file name of your new " | ||
| + | ====Using multiple deep zoom images==== | ||
| + | The next [[https:// | ||
| + | * A Composition at the top-level. | ||
| + | * A number of smaller Compositions for building a simple menu. | ||
| + | * A Book for showing the image selected on the menu. | ||
| + | |||
| + | The menu buttons each have two actions; one setting a Spot Parameter subsequently used to control the // | ||
| + | The close button returns to the menu. | ||
| - | ====Prepare the images for deep zoom==== | + | {{: |
| - | A computer with java installed and the java default path enabled in the enviroment variables. | + | The Web Block uses feature allowing you to pass Spot Parameters to a custom web page as query parameters. Here we pass the // |
| - | This can be tested | + | |
| - | We have used the java application Pyramido-cli to prepare the deep zoom content. | + | |
| - | The tool can be downloaded | + | {{: |
| - | Credits to the employees at National Institute of Standards and Technology for writing and sharing the program. | + | |
| - | Unpack the zipfile om your harddrive. | ||
| - | | ||
| - | Browse to the folder where the tool is located. | + | ===Using query parameters from custom HTML content=== |
| - | Inside the folder | + | Below you can see how you can use query parameters from within custom HTML code. This is similar |
| - | As an alternative a terminal can be opened in the tools directory. Run the following command in the terminal window. | + | < |
| - | < | + | < |
| - | To select another source file just copy the file to the same directory as the tool and change hr.jpg in the commmand to the name of your new file. The result will end up in the //out// directory prefixed with the source file name. | + | <html lang=" |
| - | + | < | |
| - | Copy the resulting file and folder from inside the //out// directory to your deep zoom block' | + | <meta charset=" |
| - | + | < | |
| - | The file name of the new dzi source has to be specified in the custom blocks //index.html// file. Find the line specifying the // | + | < |
| - | + | html, body { | |
| - | + | margin:0; | |
| - | ====A block example using multiple dzi source files==== | + | padding: 0; |
| - | + | } | |
| - | This example uses a modified verion of the custom index.html file that accepts queryparameters. This make is possible to control the tileSource form by sending queryparameters. A queryparameter is the options that can be sent to a website using a ? to tell the webpage that there are queryparameters to follow. One can use multiple queryparameters separated by &. | + | # |
| - | + | width: 800px; height: 800px; | |
| - | The example block can be downloaded | + | } |
| - | + | </style> | |
| - | The block is a composition at toplevel. Inside a couple of small compositions that builds our menu. The book that acts as an overlay that loads the webpage controlled | + | </head> |
| - | The buttons triggs two actions each, one that set a parameter to a string, the value is the path to the tileSource. Ie. //out/ | + | < |
| - | When the user closes with the close button the menu is exposed and a new selection can be made by the user. | + | < |
| - | + | <script src=" | |
| - | {{:blocks:app-note:deep-zoom: | + | <script type=" |
| - | + | ||
| - | The web block uses a useful feature that enables us to pass the value of blocks parameters on to the custom web page as a query parameters. In this case we pass the tileSource parameters value we set with the buttons. Multiple parameters value can be passed with this method separated with a comma. | + | |
| - | + | Get the set of query params | |
| - | {{:blocks:app-note:deep-zoom:webblockconfig.jpg? | + | |
| + | */ | ||
| + | | ||
| + | if (!queryParams) { | ||
| + | const query = window.location.search.substring(1); | ||
| + | const vars = query.split(" | ||
| + | const qParams = {}; | ||
| + | if (vars.length > 0 && vars[0].length > 0) { | ||
| + | for (var i = 0; i < vars.length; i++) { | ||
| + | const pair = vars[i].split(' | ||
| + | var value = pair[1]; | ||
| + | value = value.split('?' | ||
| + | | ||
| + | } | ||
| + | } | ||
| + | queryParams = qParams; | ||
| + | } | ||
| + | return queryParams; | ||
| + | } | ||
| + | var queryParams; | ||
| + | | ||
| + | |||
| + | var viewer = OpenSeadragon({ | ||
| + | id: " | ||
| + | prefixUrl: " | ||
| + | tileSources: getQueryParams()[' | ||
| + | | ||
| + | | ||
| + | minZoomImageRatio: getQueryParams()[' | ||
| + | maxZoomPixelRatio: getQueryParams()[' | ||
| + | visibilityRatio: getQueryParams()[' | ||
| + | showNavigationControl: | ||
| + | | ||
| + | |||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | |||