NAME

Image::Magick::Tiler - Slice an image into N x M tiles.

Synopsis

#!/usr/bin/perl

use Image::Magick::Tile;

Image::Magick::Tile -> new
(
	input_file  => 'image.png',
	geometry    => '3x4+5-6',
	output_dir  => '',
	output_type => 'png',

) -> tile();

This slices image.png into 3 tiles horizontally and 4 tiles vertically.

Further, the width of each tile is ( (width of image.png) / 3) + 5 pixels, and the height of each tile is ( (height of image.png) / 4) - 6 pixels.

In the geometry option NxM+x+y, the x and y offsets can be used to change the size of the tiles.

For example, if you specify 2x3, and the vertical line which splits the image goes through an interesting part of the image, you could then try 2x3+50, say, to move the vertical line 50 pixels to the right. This is what I do when printing database schema generated with GraphViz::DBI.

Description

Image::Magick::Tiler is a pure Perl module.

Distributions

This module is available both as a Unix-style distro (*.tgz) and an ActiveState-style distro (*.ppd). The latter is shipped in a *.zip file.

See http://savage.net.au/Perl-modules.html for details.

See http://savage.net.au/Perl-modules/html/installing-a-module.html for help on unpacking and installing each type of distro.

Constructor and initialization

new(...) returns a Image::Magick::Tiler object.

This is the class's contructor.

Parameters:

input_file

This parameter is mandatory.

geometry

This parameter is optional.

It's format is 'NxM+x+y'.

The default is '2x2+0+0'.

N is the default number of tiles in the horizontal direction.

M is the default number of tiles in the verical direction.

The N and/or M component can be omitted. 2 is assumed for any missing N or M. The 'x' is optional if M is missing. A single value, such as '5', is assumed to be an N value, and M is set to 2.

The '+x+y' component can be omitted. 0 is assumed for any missing x and y adjustments to the width and height of the tiles. A single value, such as '+5', is assumed to be an x value, and y is set to 0.

Negative or positive values can be used for x and y. Negative values will probably cause extra tiles to be required to cover the image. That why I used the phrase 'default number of tiles' above.

An example would be '2x3-10-12'.

output_dir

This parameter is optional.

The default is ''.

output_type

This parameter is optional.

The default is 'png'.

return

This parameter is optional.

It takes the values 0 and 1.

The default value is 1.

Setting it to 0 causes sub tile() to return an empty array ref.

Presumably you've set option 'write' to 1 to write the tiles to disk in this case.

Setting return to 1 causes sub tile() to return an array ref of elements.

Each element is a hashref, with these keys:

file_name

This is an automatically generated file name.

When the geometry is '2x3', say, the file names are of the form 1-1.png, 1-2.png, 2-1.png, 2-2.png, 3-1.png and 3-2.png.

image

This is the Image::Magick object for one tile.

verbose

This parameter is optional.

It takes the values 0 and 1.

The default value is 0.

Setting it to 1 causes various information to be written to STDOUT.

write

This parameter is optional.

It takes the values 0 and 1.

The default value is 0.

This value causes tiles to be not written to disk.

Setting it to 1 causes the tiles to be written to disk using the automatically generated files names as above.

Method: new(...)

Returns a object of type Image::Magick::Tiler.

See above, in the section called 'Constructor and initialization'.

Method: tile()

Returns an array ref, which may be empty. See the 'return' option above for details.

Author

Image::Magick::Tiler was written by Ron Savage <ron@savage.net.au> in 2005.

Home page: http://savage.net.au/index.html

Copyright

Australian copyright (c) 2005, Ron Savage. All Programs of mine are 'OSI Certified Open Source Software'; you can redistribute them and/or modify them under the terms of The Artistic License, a copy of which is available at: http://www.opensource.org/licenses/index.html