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-28 05:54] – [Prepare the images for deep zoom] 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===== |
| + | :!: **IMPORTANT**: | ||
| + | ---- | ||
| - | Blocks has at time of writing this note not any native feature for curating and publich | + | 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:// |
| + | 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 | ||
| - | ====Try deep zoom==== | ||
| - | Download {{ : | + | ====Using the deep zoom block==== |
| - | {{: | + | To try out a deep zoom image on your own Blocks server, do as follows: |
| - | If you rather try it out with a mobile device and a visitor spot, you may want to {{ : | + | * Download |
| + | * Import it into your Blocks server using the Import Block. command | ||
| + | * Drag the resulting block onto a Display Spot, preferably one connected to a touch screen (for testing, you can also use a mouse with a scroll wheel). | ||
| + | * Pinch (or use the scroll wheel) to zoom into the image. | ||
| + | {{: | ||
| - | ====How does it work==== | + | Here's {{ : |
| - | This block has a custom component that is stored in the example blocks. This makes it self-contained and can be distributed via the editor. | + | ====Inside |
| - | Open the zip file in finder/ | + | |
| - | You should see something like this: | + | The two blocks mentioned above bundles a custom web page with the pyramidal representation of the image. Normally, you wouldn' |
| {{: | {{: | ||
| - | Where the files //Spec.pixi, Meta, | + | The //Spec.pixi// and //Meta, |
| {{: | {{: | ||
| - | //Index.html// | + | The //index.html// |
| - | //Openseadragon.min.js// is the js library | + | 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 references the external library and the rest initialises the viewer with its settings. | + | ====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> | + | |
| + | Then go ahead and {{: | ||
| + | Extract the // | ||
| - | The API documentation can be found [[https://openseadragon.github.io/docs/|here]]. | + | Two script files are included, showing how to use the command line program; |
| - | Find the openseadragon licence conditions[[https: | + | |
| + | < | ||
| + | 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 | |
| - | ====Prepare | + | |
| - | + | ||
| - | To use this guide you need java installed and the java path specified as an environment variable. | + | |
| - | This can be tested by open a terminal and type java and hit enter. If java is installed and the path is specified in environment variables, java should start and a list of available java options is presented in the terminal. | + | The menu buttons each have two actions; |
| - | + | The close button | |
| - | This example uses the java application Pyramido-cli to process the content. | + | |
| - | + | ||
| - | The tool can be downloaded {{: | + | |
| - | Credits to the employees at National Institute of Standards and Technology for writing and sharing the program. | + | |
| - | + | ||
| - | Extract the zipfile to your hard drive. | + | |
| - | Inside the extracted folder you will find a high-resolution example file. The tool support both jpg and png. It is important that the colour format is RGB 8bit. If it is not, the image must be converted by open it and change the settings in a photo editor. | + | |
| - | + | ||
| - | Browse to the folder where the tool was extracted. | + | |
| - | + | ||
| - | Inside the folder you can find a // | + | |
| - | + | ||
| - | As an alternative | + | |
| - | < | + | |
| - | To select another source file 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 file name. | + | |
| - | + | ||
| - | Copy the resulting file and folder from inside | + | |
| - | + | ||
| - | The file name of the new dzi source must be specified | + | |
| - | + | ||
| - | + | ||
| - | ====A block example using multiple dzi source files==== | + | |
| - | + | ||
| - | This example uses a modified version of the custom index.html file that accepts query parameters. This make is possible to control the tileSource form by sending query parameters. A query parameter is the options that can be sent to a website using a ? to tell the webpage that there are query parameters to follow. One can use multiple query parameters separated by &. | + | |
| - | + | ||
| - | The example block can be downloaded [[https:// | + | |
| - | + | ||
| - | The block is a composition at top-level. Inside a couple of small compositions that builds our menu. The book that acts as an overlay that loads the webpage controlled by the buttons. | + | |
| - | The buttons trigs two actions each, one that set a parameter to a string, the value is the path to the tileSource. Ie. // | + | |
| - | When the user closes with the close button the menu is exposed, and a new selection can be made by the user. | + | |
| {{: | {{: | ||
| - | The web block uses a useful | + | The Web Block uses feature |
| {{: | {{: | ||
| - | ====Query | + | ===Using query parameters |
| + | |||
| + | Below you can see how you can use query parameters from within custom HTML code. This is similar to the example shown earlier, but adds some code to extract and use query parameters, here for setting a number of deep zoom options. Additional options can be added as query parameters, as needed. | ||
| - | This example can also be useful to demonstrate the code required to use query parameters in pages. Compare to the simple example from the beginning of this application note. | ||
| < | < | ||
| < | < | ||
| <html lang=" | <html lang=" | ||
| - | < | + | |
| - | <meta charset=" | + | <meta charset=" |
| - | < | + | < |
| - | < | + | < |
| - | html, body { | + | html, body { |
| - | margin:0; | + | margin:0; |
| - | padding: 0; | + | padding: 0; |
| - | } | + | } |
| - | # | + | # |
| - | width: 800px; height: 800px; | + | width: 800px; height: 800px; |
| - | } | + | } |
| - | </ | + | </ |
| - | </ | + | </ |
| - | < | + | < |
| - | <div id=" | + | <div id=" |
| - | <script src=" | + | <script src=" |
| - | <script type=" | + | <script type=" |
| - | + | ||
| - | /** | + | /** |
| - | * Get the set of query params specified in URL, building it if not yet done. | + | |
| - | */ | + | Returned as a dictionary with key/value pairs. |
| - | function getQueryParams() { | + | */ |
| - | if (!queryParams) { | + | function getQueryParams() { |
| - | const query = window.location.search.substring(1); | + | if (!queryParams) { |
| - | const vars = query.split("&" | + | const query = window.location.search.substring(1); |
| - | const qParams = {}; | + | const vars = query.split("&" |
| - | if (vars.length > 0 && vars[0].length > 0) { // Got some fish | + | const qParams = {}; |
| - | for (var i = 0; i < vars.length; | + | if (vars.length > 0 && vars[0].length > 0) { // Got some fish |
| - | const pair = vars[i].split(' | + | for (var i = 0; i < vars.length; |
| - | var value = pair[1]; | + | const pair = vars[i].split(' |
| - | value = value.split('?' | + | var value = pair[1]; |
| - | qParams[pair[0]] = value; | + | value = value.split('?' |
| - | } | + | qParams[pair[0]] = value; |
| - | } | + | } |
| - | queryParams = qParams; | + | } |
| - | } | + | queryParams = qParams; |
| - | return queryParams; | + | } |
| - | } | + | return queryParams; |
| - | var queryParams; | + | } |
| - | + | var queryParams; | |
| - | + | | |
| - | + | ||
| - | | + | var viewer = OpenSeadragon({ |
| id: " | id: " | ||
| prefixUrl: " | prefixUrl: " | ||
| tileSources: | tileSources: | ||
| - | minZoomLevel: | + | |
| - | maxZoomLevel: | + | maxZoomLevel: |
| - | minZoomImageRatio: | + | minZoomImageRatio: |
| - | maxZoomPixelRatio: | + | maxZoomPixelRatio: |
| - | visibilityRatio: | + | visibilityRatio: |
| - | showNavigationControl: | + | showNavigationControl: |
| - | }); | + | }); |
| - | + | ||
| - | + | </ | |
| - | + | </ | |
| - | + | ||
| - | </ | + | |
| - | </ | + | |
| </ | </ | ||
| </ | </ | ||
| - | |||