Update documentation

This commit is contained in:
Justin Hawkins 2024-06-04 08:48:33 +09:30
parent 75027684ec
commit 69b3360d79
2 changed files with 41 additions and 5 deletions

View File

@ -3,8 +3,8 @@
Slice and dice an image, turning it into many equal sized tiles. Useful Slice and dice an image, turning it into many equal sized tiles. Useful
for tools like leaflet.js, to create interactive "slippy" maps. for tools like leaflet.js, to create interactive "slippy" maps.
The image is sliced up into equal sized tiles, based on the command line The image is sliced up into equal sized tiles, based on the command line
option `--tile-size` (default 256 pixels). option `--tile-size` (default 256 pixels).
Once the tiling is finished, the original is resized to half its current 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. dimensions (the orignal file on disk is not touched) and the process repeats.
@ -19,9 +19,46 @@ the top left tile.
## Usage ## 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 ## Notes

View File

@ -234,7 +234,6 @@ func tileWorker(jobs <-chan tileJob, results chan<- string) {
writer, err := j.output.CreatePathAndFile(output_filename) writer, err := j.output.CreatePathAndFile(output_filename)
if err != nil { if err != nil {
log.Fatalf("could not create path/file: '%s'", err.Error()) log.Fatalf("could not create path/file: '%s'", err.Error())
panic(err)
} }
if j.format == "png" { if j.format == "png" {
err = png.Encode(writer, cropped) err = png.Encode(writer, cropped)