The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Graphics::DZI - DeepZoom Image Pyramid Generation

SYNOPSIS

  use Graphics::DZI;
  my $dzi = Graphics::DZI::A4 (image    => $image,
                               overlap  => $overlap,
                               tilesize => $tilesize,
                               format   => $format,
                               );

  write_file ('/var/www/xxx.xml', $dzi->descriptor);
  $dzi->iterate ();
  # !!! this does only display the tiles on the screen
  # !!! see Graphics::DZI::Files for a subclass which 
  # !!! actually writes to files

DESCRIPTION

This base package generates tiles from a given image in such a way that they follow the DeepZoom image pyramid scheme. Consequently this image becomes zoomable with tools like Seadragon.

  http://en.wikipedia.org/wiki/Deep_Zoom

As this is a base class, you may want to look either at the deepzoom script which operators on the command line, or at one of the subclasses.

INTERFACE

Constructor

The constructor accepts the following fields:

image

The Image::Magick object which is used as canvas.

scale (integer, default: 1)

Specifies how much the image is stretched in the process.

overlap (integer, default: 4)

Specifies how much the individual tiles overlap.

tilesize (integer, default: 128)

Specifies the quadratic size of each tile.

overlays (list reference, default: [])

An array of Graphics::DZI::Overlay objects which describe how further images are supposed to be composed onto the canvas image.

Methods

crop

$tile = $dzi->crop ($scale, $x, $y, $dx, $dy)

Given the dimensions of a tile and a current (not the original) stretch factor this method will return a tile object.

dimensions

($W, $H) = $dzi->dimensions ('total')

($W, $H) = $dzi->dimensions ('canvas')

This method computes how large (in pixels) the overall image will be. If canvas is passed in, then any overlays are ignored. Otherwise their size (with their squeeze factors) are used to blow up the canvas, so that the overlays fit onto the canvas.

iterate

$dzi->iterate

This method will generate all necessary tiles, invoking the manifest method. You may want to override that one, if you do not want the tiles to be simply displayed on screen :-) Any options you add as parameters will be passed on to manifest.

manifest

$dzi->manifest ($tile, $level, $row, $col)

This method will get one tile as parameter and will simply display the tile on the screen. Subclasses which want to persist the tiles, can use the additional parameters (level, row and column) to create file names.

descriptor

$string = $dzi->descriptor

This method returns the DZI XML descriptor as string.

TODOs

See the TODOs file in the distribution.

AUTHOR

Robert Barta, <drrho at cpan.org>

COPYRIGHT & LICENSE

Copyright 2010 Robert Barta, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.