From 69b3360d794f8b4929a9e9395eeb23fffdf4bd5d Mon Sep 17 00:00:00 2001 From: Justin Hawkins Date: Tue, 4 Jun 2024 08:48:33 +0930 Subject: [PATCH] Update documentation --- README.md | 45 +++++++++++++++++++++++++++++++++++++++++---- main.go | 1 - 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 12102f3..8f93a3f 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,8 @@ Slice and dice an image, turning it into many equal sized tiles. Useful for tools like leaflet.js, to create interactive "slippy" maps. -The image is sliced up into equal sized tiles, based on the command line -option `--tile-size` (default 256 pixels). +The image is sliced up into equal sized tiles, based on the command line +option `--tile-size` (default 256 pixels). Once the tiling is finished, the original is resized to half its current dimensions (the orignal file on disk is not touched) and the process repeats. @@ -19,9 +19,46 @@ the top left tile. ## Usage - slicerdicer --help + slicerdicer -help - slicerdicer --filename foo.png --tile-size 256 --concurrency 5 + slicerdicer -filename large_image.png -tile-size 256 -concurrency 5 + +## Output filenames + +The destination for the tiles can be changed with the `-basename` and +`-path-template` options. The path template must contain 5 placeholders, +in the following order: + +* `%s` basename, as per `-basename` (default `tile`) +* `%d` zoom level +* `%d` 'x' coordinate +* `%d` 'y' coordinate +* `%d` file format (jpg or png) + +The default template is `%s-%d-%d-%d.%s` which results in a flat structure +with all files in the current directory. + +For example, using `-basename map` and +`-path-template '%s/zoom-%d/%d-%d.%s'` will result in a file structure like: + + map + ├── 0 + │   └── 0-0.png + ├── 1 + │   ├── 0-0.png + │   └── 1-0.png + └── 2 + ├── 0-0.png + ├── 0-1.png + ├── 1-0.png + ├── 1-1.png + ├── 2-0.png + ├── 2-1.png + ├── 3-0.png + └── 3-1.png + +All tiles in a directory called `map`, with a second level directory for zoom +level, each file named `x-y.png` within that. ## Notes diff --git a/main.go b/main.go index 7daf1e3..0c6abc1 100644 --- a/main.go +++ b/main.go @@ -234,7 +234,6 @@ func tileWorker(jobs <-chan tileJob, results chan<- string) { writer, err := j.output.CreatePathAndFile(output_filename) if err != nil { log.Fatalf("could not create path/file: '%s'", err.Error()) - panic(err) } if j.format == "png" { err = png.Encode(writer, cropped)