SSTiles — Stupid Simple Tile Maker

SSTiles is a small project I’ve been working on. It’s a simple PHP script that generates XYZ slippy map tiles on demand.

Ideally you’ll use a correctly projected base image (a square image, in Web Mercator projection). Since the image is square, SSTiles will just slice it up, no scaling is needed.


Usage is simple. Place the sstiles.php library and the tile.php or pad.php helper script in a directory with your base map, and add the layer to your map like so:$Z/$X/$Y.png

For Leaflet, you would do:


For OpenLayers you would do:
var basemap = new OpenLayers.Layer.XYZ("Basemap", "${z}/${x}/${y}.png");

Basemap types


A Nice Square Map

A Nice Square Map

Other times it might not matter if the map is correctly projected, in which case you can use a non-square image which will be sliced and scaled so that resulting tiles are square.


A Non-Square Map Is Stretched To Be Square


And finally, for the real use case that I wrote this script, if you want to abuse Leaflet (or OpenLayers, etc.) to make a tiled image viewer for high-resolution images you can ask SSTiles to pad the image so that resulting tiles won’t be distorted.




  • Lets you use any image as a slippy map!
  • Generates slippy-map tiles from a single top-level image!
  • Stretches the image if it’s not square!
    • OR Pads the image if it’s not square!
  • Caches generated tiles!
  • Auto-updates cache when source file is updated!
  • Sends HTTP caching headers!
  • Supports GD and ImageMagick!