DeepZoom (Part I): The deepzoom Script

If installed properly, the Graphics::DZI distribution should also contain a script deepzoom which can be used from the command line.

With it you can take an image (in any format ImageMagick can interpret) and generate the image pyramid as necessary for deep zooming with the Seadragon AJAX client.

Messing With Files and Directories

The basic usage is fairly straightforward:

deepzoom product.png

will create all the necessary files:

  • a product.xml to bootstrap the client, and
  • all tiles of the pyramid in a product_files directory.

All will end up in your current working directory.

If that is not your intent, then you can point to the target directory with a --path switch:

deepzoom --path=/where/ever/ product.png

Don't forget the trailing /). Further you can also control the naming (--prefix). Later I also want to add something like this:

deepzoom --dzi=/where/ever/prod.dzi product.png

which would specify the name of the XML document explicitly (and the place of the tiles implicitely).

Operational Switches

You can also control the format of the tiles (--format):

PNG as format works well, but as PNG is designed to be lossfree, it will use up (a) disk space and then later (b) bandwidth. If you know that your image does not have many regions with a lot of detail, then maybe JPEG (JPG) is to be favoured.

One other thing you may want to consider is the size of the tiles. The default 256 is ok, but if you create zoomable images from a document snapshot you will find that larger tiles are faster to load.

There is also a parameter to control the tile overlap (usually a small number of pixels). I never found a need to change the default (4). But it is possible.

Tactical Switches

Normally you will want to take a single high resolution picture as source. If - for some reason - you want to rescale the image during the tiling process, then you can do so with --stretch:

deepzoom --stretch=2 product.png

The difference to actually resizing the image upfront, is that the resizing will only be virtual, and does not take up additional memory. There is a certain loss of precision though.

You can also specify more than one input image, so that for each of these a separate DZI is produced.

Zoomable Documents

I also have covered a slightly different use case: I take hires pictures of documents and then convert the individual pages into a zoomable image.

As this is one coherent document, I want (maybe you too) to have first only the first page visible. Then - at deeper zoom levels - more pages become visible. Have a look at one demo.

To achieve that, you can have all pages as arguments, and use the --document switch:

deepzoom --document=linear pages*.png

How aggressively more pages are added can be controlled. In the linear mode the sequence of pages shown is 1x1, 2x2, 3x3, 4x4, etc. In the exponential mode this is 1x1, 2x2, 4x4, 16x16 and so forth.

Happy Zooming!

Posted In