Project

imagetiler

0.01
No commit activity in last 3 years
No release in over 3 years
imagetiler is a simple command-line and ruby image tiler with support for multiple zoom levels and different image formats.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

imagetiler -- A simple tool to tile images.

imagetiler is a simple command-line and ruby image tiler with support for multiple zoom levels and different image formats.

How to use

First install ImageMagick, then rmagick.

From the command line

imagetiler.rb is in the lib directory.

ruby imagetiler.rb -o OUTPUT_DIR -z ZOOM_LEVELS IMAGE_FILE

For example

ruby imagetiler.rb -o ./tiles -z 2..4 ./input_files/map.jpg

From ruby

Install the gem:
gem install imagetiler

Use it in your code:
require 'rubygems' # if you installed imagetiler as a gem require 'imagetiler' t = Tiler.new
t.make_tiles(image_source, opts)

image_source can be either a filename or an RMagick Image.

You can set options two ways:
t.zoom_levels = 2..4
or
t.get_tiles(image, :zoom_levels => 2..4)

If you set an option in get_tiles, that will be the new default for that instance of Tiler.

Options

zoom_levels : Zoom level 0 shows the entire image as one 256x256 tile. Subsequent zoom levels double both the horizontal and vertical sides. Default is 0..4
output_dir : Defaults to the current directory. bg_color : The background fill color, transparent by default.
autocreate_dirs : Whether or not to create the directory if it exists. Default true
format : The format for the output, defaults to 'png'. Can be png, jpg, gif, or anything that ImageMagick supports.
prefix : Prefix for the output files. Defaults to 'tile'

Methods

make_tiles(image_source, opts)

calc_native_res_zoom : Calculates the zoom level closest to native resolution. Returns a float for the zoom -- so, use zoom.round if you want the closest zoom level, for example.

Output

Tiles in the output folder with format
#{output_dir}/#{prefix}_#{zoom_level}_#{tile_col}_#{tile_row}.#{image_format}

Other things

  • Requires rmagick and ImageMagick.

Credits

This tiler is modified Guilhem's tile_image.rb tool, which is part of the ym4r project. The Tiler itself has been re-written, and TileParam is no longer used.
Thanks to Guilhem for the command-line portions and the sample ruby and rmagick code!

License

imagetiler uses the MIT License.