Skip to content

Barebones OpenSeadragon viewer

Make DZI files from SVS

Download latest OpenSeadragon

Organise files:1

static/
  dzi/
    foo.dzi
    foo_files/
      ...
  index.html
  openseadragon/
    images/
      ...
    openseadragon.js
    openseadragon.min.js
main.go

Basic index.html:

index.html
<html>
  <head>
    <style type="text/css">
      #foo {
        width: 100%;
        height: 100%;
      }
    </style>
  </head>
  <body>
    <div id="foo"></div>
    <script src="openseadragon/openseadragon.min.js"></script>
    <script>
      var viewer = OpenSeadragon({
        id:            'foo',
        prefixUrl:     'openseadragon/images/',
        tileSources:   'dzi/foo.dzi'
      });
    </script>
  </body>
</html>

Serve it with Go:

main.go
package main

import (
  "net/http"
)

func main() {
  fs := http.FileServer(http.Dir("static"))
  http.Handle("/", fs)

  http.ListenAndServe(":8080", nil)
}

go run main.go