tiledimage 0.2.2__tar.gz → 0.4__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tiledimage
3
- Version: 0.2.2
3
+ Version: 0.4
4
4
  Summary: tools for tiled image that can be cached on a filesystem.
5
5
  License: MIT
6
6
  Author: vitroid
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "tiledimage"
3
- version = "0.2.2"
3
+ version = "0.4"
4
4
  description = "tools for tiled image that can be cached on a filesystem."
5
5
  authors = ["vitroid <vitroid@gmail.com>"]
6
6
  license = "MIT"
@@ -12,8 +12,8 @@ pylru = "^1.2.1"
12
12
  opencv-python-headless = "^4.11.0.86"
13
13
 
14
14
  [tool.poetry.scripts]
15
- pngs2 = "pngs2:main"
16
- 2pngs = "2pngs:main"
15
+ pngs2 = "tiledimage.pngs2:main"
16
+ 2pngs = "tiledimage.2pngs:main"
17
17
 
18
18
  [build-system]
19
19
  requires = ["poetry-core"]
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env python
2
+
3
+ import sys
4
+
5
+ import cv2
6
+
7
+ import tiledimage.cachedimage as ci
8
+
9
+
10
+ def main():
11
+ if len(sys.argv) not in (3, 4):
12
+ print("Convert a image to a tiled image.\n")
13
+ print("usage: pngs2 from_image to_image.pngs [tilesize]\n")
14
+ sys.exit(1)
15
+ tilesize = 64
16
+ if len(sys.argv) == 4:
17
+ tilesize = int(sys.argv[3])
18
+ image = cv2.imread(sys.argv[1])
19
+ with ci.CachedImage(
20
+ "new", dir=sys.argv[2], tilesize=(tilesize, tilesize)
21
+ ) as cimage:
22
+ cimage.put_image((0, 0), image)
23
+
24
+
25
+ if __name__ == "__main__":
26
+ main()
@@ -94,8 +94,5 @@ class CachedImage(TiledImage):
94
94
  )
95
95
  self.tiles.adjust_cache_size()
96
96
 
97
- def _set_hook(self, hook):
98
- """
99
- 内部実装用:タイル書き換え時のフック関数を設定
100
- """
97
+ def set_hook(self, hook):
101
98
  self.tiles.set_hook(hook)
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env python
2
+
3
+ from __future__ import print_function
4
+
5
+ import sys
6
+
7
+ import cv2
8
+
9
+ import tiledimage.cachedimage as ci
10
+
11
+
12
+ def main():
13
+ if len(sys.argv) != 3:
14
+ print("Convert an image tile to a single image.\n")
15
+ print("usage: pngs2 from_image.pngs to_image.[jpg|png|...]\n")
16
+ sys.exit(1)
17
+ with ci.CachedImage("inherit", dir=sys.argv[1]) as image:
18
+ image = image.get_image()
19
+ cv2.imwrite(sys.argv[2], image)
20
+
21
+
22
+ if __name__ == "__main__":
23
+ main()
File without changes