Graphics::DZI - DeepZoom Image Pyramid Generation
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
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.
The constructor accepts the following fields:
image
The Image::Magick object which is used as canvas.
scale
Specifies how much the image is stretched in the process.
overlap
Specifies how much the individual tiles overlap.
tilesize
Specifies the quadratic size of each tile.
overlays
An array of Graphics::DZI::Overlay objects which describe how further images are supposed to be composed onto the canvas image.
$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.
($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.
canvas
$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.
$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.
$string = $dzi->descriptor
This method returns the DZI XML descriptor as string.
See the TODOs file in the distribution.
Robert Barta, <drrho at cpan.org>
<drrho at cpan.org>
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.
To install Graphics::DZI, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Graphics::DZI
CPAN shell
perl -MCPAN -e shell install Graphics::DZI
For more information on module installation, please visit the detailed CPAN module installation guide.