Demo of the OpenSeadragon scalebar plugin. Code and documentation are available on GitHub.
Change the properties of the scalebar to visualize the effects.