poster-tile-planner 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- poster_tile_planner/__init__.py +65 -0
- poster_tile_planner-0.1.0.dist-info/METADATA +36 -0
- poster_tile_planner-0.1.0.dist-info/RECORD +7 -0
- poster_tile_planner-0.1.0.dist-info/WHEEL +5 -0
- poster_tile_planner-0.1.0.dist-info/entry_points.txt +2 -0
- poster_tile_planner-0.1.0.dist-info/licenses/LICENSE +21 -0
- poster_tile_planner-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"""Calculate tiled print layouts in millimetres."""
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
import json
|
|
5
|
+
from math import ceil
|
|
6
|
+
from decimal import Decimal, InvalidOperation
|
|
7
|
+
from fractions import Fraction
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def millimetres(text):
|
|
11
|
+
try:
|
|
12
|
+
value = Decimal(text)
|
|
13
|
+
if value.is_finite() and 0 <= value <= 1_000_000 and value.as_tuple().exponent >= -3:
|
|
14
|
+
return Fraction(value)
|
|
15
|
+
except InvalidOperation:
|
|
16
|
+
pass
|
|
17
|
+
raise argparse.ArgumentTypeError("enter 0 to 1000000 mm with up to three decimal places")
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def tile_count(length, printable, overlap):
|
|
21
|
+
if length <= printable:
|
|
22
|
+
return 1
|
|
23
|
+
return 1 + ceil((length - printable) / (printable - overlap))
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def main():
|
|
27
|
+
parser = argparse.ArgumentParser(description=__doc__)
|
|
28
|
+
parser.add_argument("--poster", nargs=2, type=millimetres, required=True, metavar=("WIDTH", "HEIGHT"))
|
|
29
|
+
parser.add_argument("--paper", nargs=2, type=millimetres, required=True, metavar=("WIDTH", "HEIGHT"))
|
|
30
|
+
parser.add_argument("--margin", type=millimetres, default=Fraction(0), help="Uniform margin on each edge")
|
|
31
|
+
parser.add_argument("--overlap", type=millimetres, default=Fraction(0), help="Overlap between neighbouring tiles")
|
|
32
|
+
args = parser.parse_args()
|
|
33
|
+
|
|
34
|
+
width, height = args.poster
|
|
35
|
+
printable_width, printable_height = (size - 2 * args.margin for size in args.paper)
|
|
36
|
+
if min(width, height) <= 0:
|
|
37
|
+
parser.error("poster dimensions must be positive")
|
|
38
|
+
if min(printable_width, printable_height) <= args.overlap:
|
|
39
|
+
parser.error("both printable dimensions must exceed the overlap")
|
|
40
|
+
|
|
41
|
+
columns = tile_count(width, printable_width, args.overlap)
|
|
42
|
+
rows = tile_count(height, printable_height, args.overlap)
|
|
43
|
+
if rows * columns > 10_000:
|
|
44
|
+
parser.error("layout exceeds the 10000-tile limit")
|
|
45
|
+
|
|
46
|
+
tiles = []
|
|
47
|
+
for row in range(rows):
|
|
48
|
+
for column in range(columns):
|
|
49
|
+
left = column * (printable_width - args.overlap)
|
|
50
|
+
top = row * (printable_height - args.overlap)
|
|
51
|
+
right = min(left + printable_width, width)
|
|
52
|
+
bottom = min(top + printable_height, height)
|
|
53
|
+
tiles.append({
|
|
54
|
+
"row": row + 1,
|
|
55
|
+
"column": column + 1,
|
|
56
|
+
"source_box_mm": [float(edge) for edge in (left, top, right, bottom)],
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
print(json.dumps({
|
|
60
|
+
"rows": rows,
|
|
61
|
+
"columns": columns,
|
|
62
|
+
"total_pages": len(tiles),
|
|
63
|
+
"printable_area_mm": [float(printable_width), float(printable_height)],
|
|
64
|
+
"tiles": tiles,
|
|
65
|
+
}, indent=2))
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: poster-tile-planner
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Plan poster printing across sheets using physical dimensions, margins, and overlap.
|
|
5
|
+
Author: js-upup
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Tiled Printing, https://tiledprinting.org/
|
|
8
|
+
Keywords: printing,poster,tiles,paper
|
|
9
|
+
Requires-Python: >=3.9
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Dynamic: license-file
|
|
13
|
+
|
|
14
|
+
# Poster Tile Planner
|
|
15
|
+
|
|
16
|
+
Calculate how many physical sheets a large poster needs, then export the layout
|
|
17
|
+
as JSON for a print or cropping workflow. Runs locally with Python 3.9+ and has
|
|
18
|
+
no third-party runtime dependencies.
|
|
19
|
+
|
|
20
|
+
```sh
|
|
21
|
+
pip install poster-tile-planner
|
|
22
|
+
poster-tile-planner --poster 600 400 --paper 210 297 --margin 5 --overlap 10
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
This layout uses two rows and four columns, with a 200 x 287 mm printable area.
|
|
26
|
+
Each tile has a one-based row and column and a source box in millimetres
|
|
27
|
+
`[left, top, right, bottom]`, measured from the poster's top-left corner.
|
|
28
|
+
For example, the first tile covers `[0.0, 0.0, 200.0, 287.0]`.
|
|
29
|
+
|
|
30
|
+
Set paper width and height in the desired orientation. The same margin is applied
|
|
31
|
+
to all paper edges. Neighbouring tiles share the requested overlap, and tiles
|
|
32
|
+
at the right and bottom edges stop at the poster boundary. This tool returns
|
|
33
|
+
geometry for up to 10,000 sheets and does not render images or create a PDF.
|
|
34
|
+
|
|
35
|
+
If you already have an image and want to split it into printable pages in your
|
|
36
|
+
browser, use [Tiled Printing](https://tiledprinting.org/).
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
poster_tile_planner/__init__.py,sha256=T1T-aeYBAmh5di9_kNWdpCyRv1giPCdUokYvxucstFk,2522
|
|
2
|
+
poster_tile_planner-0.1.0.dist-info/licenses/LICENSE,sha256=Vm-Lx6SkWO7gJRvMYyHjPcUoYGeEntaSqYo5UEZ2ags,1064
|
|
3
|
+
poster_tile_planner-0.1.0.dist-info/METADATA,sha256=8zAWwZzrAJNHYIcbcqxQXf9gpJSYfJQA5kbv7OoAyE8,1483
|
|
4
|
+
poster_tile_planner-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
5
|
+
poster_tile_planner-0.1.0.dist-info/entry_points.txt,sha256=vv2IiVsTLdcCHOaB5RwfnV64zNM5vCXV59463i0I7_0,65
|
|
6
|
+
poster_tile_planner-0.1.0.dist-info/top_level.txt,sha256=0hUa6VKyym4lOqc9RpO7qoqkG7sDdLpxJ0VCThlPGA8,20
|
|
7
|
+
poster_tile_planner-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 js-upup
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
poster_tile_planner
|