File:Create Stitch Script.ods

From Commons Archive
Jump to navigation Jump to search
Create_Stitch_Script.ods(file size: 153 KB, MIME type: application/vnd.oasis.opendocument.spreadsheet)
Warning: This file type may contain malicious code. By executing it, your system may be compromised.


English: Helper to harvest map data from e.g.

The map is made from tiles, in this example 512 by 512 pixels each. The contributed spreadsheet (made with LibreOffice Calc) helps to create a script that downloads each tile (by means of wget) and stitches all of them together (by means of jpegtran). Note that in order to use the script, wget and a version of jpegtran with droppatch (rf. [1]) must be installed; this is typically not the case when using an Windows machine in out of the box state. Regarding the droppatch, even on Linux machines one has to take care that the installed version of jpegtran has got it.

Detailed (but nevertheless dry) description of how to use

<A more detailed description with examples, more from user’s point of view, but only in german can be found at :de:Benutzer:Pemu/Stitch-Script-Synthesizer.>

By using your browser, zoom into map upto desired (that probably means highest) zoom level, go to top rightmost tile, determine its url (e. g. by using "view this image alone" from the context menu). Despite the numbering order in the above example, most sites numbers tiles in reverse order, so, in these cases, look at the bottom righmost one. Maybe use other means to examine the urls of the tiles, e. g. Firefox’ developer tools or by using browser Chromium, opening context menu and use Inspect to examine the Sources in the just opened view. Determine column and row number of tiles, e.g from the remaning part of top righmost tile’s url or just by try and error (displaying error messages or empty tiles when entered in browser’s url field).

Split this url into two parts – the base (e. g. everything except the file name and the bottommost directory name, both consisting of numbers resembling row resp. column) and the remainder. Put the base part (including trailing slash or the like) into the cell B3 in the second line of the spreadsheet. Take determined column and row number and update cells below for no. of columns resp. rows (B4/B5). (Due to using the top-right tile’s url their values representing the resp. maximum values – in other words, the number of columns and rows minus one.) Often, rightmost and bottom tiles are smaller in size to yield a final size that isn’t a mutliple of remaining tiles’ size. To accomplish this, fill the appropriate values in cells B6 and B7; if it happens to be the same as the size of remaining tiles, just fill in the same numbers as in cells (B11 and B12). Note that currently there is no support, should the top line of tiles be smaller than the remaining ones. If necessary, adjust values for pixel width and height of each tile (cells B11/B12). Note: Putting the complete url in cell B1 has no effect except serving documentary purposes.

Depending on the fashion the website numbers the tiles adjust the multiplier, suffix and seperator (B13…B16). Insert a boolean value in B19: True, if tile numbering is from bottom to top like in a cartesian plane; false when tiles are numbered from top to bottom like in a table.

Adjust the names for commands for deleting and renaming (B28/B29) according to your OS or environment. (Linux typically "rm" and "mv", MS typically "del" and "ren".) Take also care if there should be an output redirection symbol (">") before the destination name of jpegtran and adjust B25 and B27 accordingly. (Linux versions seems to use std-out and therefore need ">", while Windows versions seems to handle file output by itself, so the ">" must be omitted)

Now select a rectangular set of cells, beginning with B31 as the top-left corner with the necessary width and height corresponding to the no. of rows and columns. The cells in column A and row 30 are coloured green to indicate the proper set of cells. Note that the coloured cells itself don’t belong to the proper set of cells. (In the given example the bottom right corner of selection is cell T40.) Copy and paste the content into an empty text file. Tab characters don’t bother. Save and execute the text file as batch file. This means that it must be named with extension of .bat or made executable, depending on your OS. Note that the cells easily appears to be empty (except for a small arrowhead to indicate they aren’t really) when sized small due to their (important) trailing newline.

After running, the file "ziel.jpg" (if not changed by means of B22) should contain the whole map.

If there are not enough cells in the rectangular set, it is easy to extend them. Note that the top row of cells is special; its commands will create a grey canvas of appropriate size, where the remaining cell’s commands will drop their tiles upon. The remaining cells are virtually equal and can be extended by selecting and using the small square in the corner of the selection to extend, resulting in copying the contents and adjusting the references to other cells. In addition, take care that in row 30 and in column A, there are continous numbers in the relevant ranges; this is easily done as well by Calc’s small-square-tool.

Brief description of functionality

The commands in cell B31 download the top left tile and pushes it to the final size (by means of a "side effect" of jpegtran’s crop option). The intermediate image contains the tile in the top left corner and a grey area at the remainder. The commands in the remaining cells download each a particular tile and replace some of the grey in the intermediate image by it (by means of jpegtran’s drop option). Note that currently the top-left tile will be download twice and dropped upon itself; this is accepted in order to keep all remaining tiles equal. Former versions of this spreadsheet had no distinct cell to blast the top-left tile to final size, but instead handled it "in set". This was annoying when using the small-square-tool, because one always had to take care of the "special" top-left cell in the rectangular set.

This procedure depends heavily on jpegtran’s lossless treatment.
If you would replace jpegtran by a tool that introduces generation loss, note that (taking a 46×36 tile map as basis) the top left tile runs through 1656 generations during stitching all tiles. Then, to minimize generation losses, using a lossless file format for intermediate images should be strongly considered.
To do
  • Including an easy-to-change feature to quickly adjust the parameter set as needed to harvest from different map hosts. Are drop down lists or radio buttons as well as indexed access to spreadsheet cells possible?
  • Don’t download first tile twice
  • Automagically tint the relevant cells according to B4/B5 to support user when selecting the right cells. Done only partly: Only the top and left adjacent cells are coloured, but not the cells forming the set itself.
Date 15 November 2017(2017-11-15)
Source Own work
Author Pemu
Other versions

File:Create Stitch Script V2.ods Experimental Version to better support sites with TileGroup folders. Beware! Contains really cobbled together bash code and demonstrates performance problems of Calc.


I, the copyright holder of this work, hereby publish it under the following license:
w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International license.
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work).
  • share alike – If you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one.

Despite technically not true, there may nevertheless be some reasons to file it under Category:Panorama stitching project files.

File history

Click on a date/time to view the file as it appeared at that time.

current23:58, 15 November 2017 (153 KB)Pemu (talk | contribs)Added
00:23, 15 September 2017 (151 KB)Pemu (talk | contribs)Added Added green background at numbering cells that should help to mark correct cells in order to copy & paste the final batch file.
02:18, 9 June 2017 (153 KB)Pemu (talk | contribs)jpegtran can't create grey images from scratch, hence give it some kind of seed to create the big canvas in the beginning. Terefore, first tile will be downloaded twice.
02:00, 9 June 2017 (153 KB)Pemu (talk | contribs)*Included an option to limit final size in case of smaller edge tiles to prevent grey residuals in final image. Not tested, just a concept demo. *Create grey canvas beforehand downloading first tile, in order to prevent top left cell from being special...
13:43, 4 June 2017 (141 KB)Pemu (talk | contribs)Added some translations
11:45, 4 June 2017 (134 KB)Pemu (talk | contribs)Changes made to use with
11:44, 1 February 2016 (23 KB)Pemu (talk | contribs)User created page with UploadWizard
  • You cannot overwrite this file.

The following page uses this file: