Giter Site home page Giter Site logo

imagetiler's Introduction

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.

imagetiler's People

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.