CanvasZoom – HTML5 Canvas and code

You may have seen the program Zoomify, or similar programs like, OpenZoom and DeepZoom, which quickly display large resolution images on websites without large amounts of data being downloaded – only the part which is needed is downloaded. Most of these applications use some kind of plugin to work (e.g. Flash or Silverlight), so I wanted to see if we could create one without any plugin, using only the HTML5 standards.

And here it is: The CanvasZoom program drawn with just the HTML5 Canvas and JavaScript. (http://www.akademy.co.uk/software/canvaszoom/canvaszoom.php)

ZoomedGalaxy

You can zoom with the mouse either with the scroll wheel – forward to zoom in, backward to zoom out – or by clicking the select button to zoom in. The buttons beneath the canvas can also be used.

Here are a few more examples:

The back-end part of the system simply consists of several folders full of images of different resolution. These images use the format that the program DeepZoom Composer generates (created by Microsoft), there’s also lots of information about the format here. The DeepZoom program currently only works on windows but once you’ve download it you can create your own zoom images, very quickly (But there’s really no reason why this DeepZoom format can’t be recreated by writing another program – something that might come later.)

There are currently no on screen controls to zoom in or out, but that should be a fairly routine addition.

Have a look at my website for details instructions on how to add the CanvasZoom to your own website here: http://www.akademy.co.uk/software/canvaszoom/canvaszoom.php

I also want to mention “Daniel Gasienica” who was the creater of OpenZoom, as he had done some of the hardwork already. See his blog here.

UPDATE (3rd May, 2011):
The CanvasZoom is now available under the MIT license so feel free to use it in any way you like. The code also had a nice clean up. The latest version is availble on GitHub here: https://github.com/akademy/CanvasZoom

UPDATE 2 (25 July, 2011):
I’m mostly working on BitBucket now. Get the latest code here: https://bitbucket.org/akademy/canvaszoom/downloads

This entry was posted in Fun, Internet, Programming, Software, Technology and tagged , , , , , , . Bookmark the permalink.

27 Responses to CanvasZoom – HTML5 Canvas and code

  1. Sean Hill says:

    This is fantastic! Very nice to see what can be done in HTML5. I am interested in extending this to support high resolution image stacks… e.g. MRI brain scans or other imaging data. So I would like to keep the same abilities of scrolling and zooming, but then add an additional control that would allow me to move through a stack of high resolution images. Any ideas? Thanks!

    • Sounds like an interesting idea. It shouldn’t be to difficult to implement assuming you have layers of images all the same size – basically just switch one image for another. You’d need a list of the images in the correct order, then just remember which is the current “layer” and navigate from one to the next.

      The creation of the tiles shouldn’t be to difficult, I think DeepZoom Composer might do multiple images at once (though the output might be slightly different), but you should be able to automate it anyway.

      It might be nice to switch between a zoom mode and a layer mode maybe via several buttons or just by holding down the ctrl key.

      I’d be interested in seeing what you produce, the easiest way to get started is to fork the project on GitHub here: https://github.com/akademy/CanvasZoom

  2. ted.northrup says:

    is there any way to get Canvaszoom working on IE8? Even with some plugin? I need to modify the 100 or so zoomified images on my sites, but IE8 is still the primary browser. Is this because IE8 can’t support the HTML5 Canvas tag?
    Yes I could use both and test for the browser but I would love to skip that step.

    Ted

  3. i added some scrolling-restriction to your code
    http://pastie.org/1730250

    it would be nice if you could state that your code is MIT or BSD licenced so one could use it for work-purpose (as i would need to)
    http://www.opensource.org/licenses/mit-license.php
    http://en.wikipedia.org/wiki/BSD_licenses

    • Sorry, i left some german comments in the code, changed the tilesize hardcoded to 512 (because i allready had some GBs of testdata with this size) and line 129 is pretty much stupidity/bug (i could have written something like:
      this.reposition((this.canvas.width – tileZoomLevel['width']) / 2, (this.canvas.height – tileZoomLevel['height']) / 2);
      to make reposition able to behave different when changed or i could have set both offset-values to zero while keeping the effect pretty much the same)

    • Now using the MIT license!

  4. Richard Beal says:

    You say CanvasZoom doesn’t work with IE, but it does work with IE9. But there is a strange problem: the mose wheel works in reverse, i.e. forwards=zoom out!

    Despite this odd problem I would very much like to use CanvasZoom for my personal website, I’m not sure if this is OK?

    You say it is work in progress. Where is the version number so I can see when you might have upgraded it?

    Thanks.

  5. Craig Taylor says:

    Hi,

    So far I am unable to get this working. Using Chrome and xampp. I cannot get any images to appear, even if I use the example. I have of course downloaded the imageloader.js script, I am confident I followed the README to the word.

    Also if I press the zoom in button a few times I get a JS error.
    “Uncaught TypeError: Cannot set property ‘strokestyle’ of null” canvaszoom.js:405

    Any help would be greatly appreciated.

  6. John says:

    Is there a way to create the backend systems on a Mac without using zoomfly composer?

  7. John says:

    Hi, just a dumb user here . . . can’t write code but is there a way for me to remove the black box line? I solved the other problem by loading parallels on my Mac so please disregard previous question.

    Cheers,
    john

  8. David says:

    Hi, I have been playing around with this and was able to get it to work perfect on IE 9 and Firefox. Is there anyway to make the page load on default with the image filling the entire square with no white spaces? Basically, zoom in on the image a couple of levels so that when the page first loads there is no white space.

  9. Great stuff! One of my interesting target platforms is the iPad, where you don’t have plugins like flash required for things like zoomify. So what I then did is play with adding touch support, with the result on my github repo: https://github.com/ptribble/CanvasZoom.

  10. John Feeman says:

    Can you constrain the zoom so that the maximum zoom out fills the window instead of being able zoom out to a single dot?

  11. Greg says:

    Hi Matthew,
    I have really enjoyed experimenting with your Canvas Zoom code. How difficult would it be to integrate annotates and/or small markers? I’m using Canvas Zoom with a map and would love to be able to mark it up a little.
    Thanks!
    Greg

Leave a Reply

Your email address will not be published. Required fields are marked *

To comment, click below to log in.

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>