diff --git a/PyTexturePacker/MaxRectsPacker/MaxRectsAtlas.py b/PyTexturePacker/MaxRectsPacker/MaxRectsAtlas.py index 0c3c52e..ac77e6b 100644 --- a/PyTexturePacker/MaxRectsPacker/MaxRectsAtlas.py +++ b/PyTexturePacker/MaxRectsPacker/MaxRectsAtlas.py @@ -154,7 +154,7 @@ def rank(self, main_rect, sub_rect, method=RANK_BSSF): return tmp def find_best_rank(self, image_rect, enable_rotated=False): - if enable_rotated: + if enable_rotated and image_rect.width != image_rect.height: return self.find_best_rank_with_rotate(image_rect) else: return self.find_best_rank_without_rotate(image_rect) diff --git a/PyTexturePacker/PackerInterface/AtlasInterface.py b/PyTexturePacker/PackerInterface/AtlasInterface.py index af0beaf..1464388 100644 --- a/PyTexturePacker/PackerInterface/AtlasInterface.py +++ b/PyTexturePacker/PackerInterface/AtlasInterface.py @@ -38,7 +38,7 @@ def __init__(self, width=1, height=1, max_width=MAX_WIDTH, max_height=MAX_HEIGHT self.image_rect_list = [] - def dump_plist(self, texture_file_name="", input_base_path=None, atlas_format=ATLAS_FORMAT_PLIST): + def dump_plist(self, texture_file_name="", input_base_path=None, atlas_format=ATLAS_FORMAT_PLIST, trim_sprite_names=False): import os plist_data = {} @@ -59,6 +59,10 @@ def dump_plist(self, texture_file_name="", input_base_path=None, atlas_format=AT else: path = os.path.relpath(os.path.abspath( path), os.path.abspath(input_base_path)) + path = path.replace('\\', '/') # for windows path + + if trim_sprite_names: + path, _ = os.path.splitext(path) if atlas_format == ATLAS_FORMAT_PLIST: frames[path] = dict( diff --git a/PyTexturePacker/PackerInterface/PackerInterface.py b/PyTexturePacker/PackerInterface/PackerInterface.py index a9791b6..c57c8b4 100644 --- a/PyTexturePacker/PackerInterface/PackerInterface.py +++ b/PyTexturePacker/PackerInterface/PackerInterface.py @@ -34,7 +34,7 @@ class PackerInterface(object): def __init__(self, bg_color=0x00000000, texture_format=".png", max_width=4096, max_height=4096, enable_rotated=True, force_square=False, border_padding=2, shape_padding=2, inner_padding=0, trim_mode=0, - reduce_border_artifacts=False, extrude=0, atlas_format=Utils.ATLAS_FORMAT_PLIST, atlas_ext=None): + reduce_border_artifacts=False, extrude=0, atlas_format=Utils.ATLAS_FORMAT_PLIST, atlas_ext=None, trim_sprite_names=False): """ init a packer :param bg_color: background color of output image. @@ -66,6 +66,7 @@ def __init__(self, bg_color=0x00000000, texture_format=".png", max_width=4096, m self.reduce_border_artifacts = reduce_border_artifacts self.atlas_format = atlas_format self.atlas_ext = atlas_ext + self.trim_sprite_names = trim_sprite_names @staticmethod def _calculate_area(image_rect_list, inner_padding): @@ -192,7 +193,7 @@ def pack(self, input_images, output_name, output_path="", input_base_path=None): texture_file_name = output_name if "%d" not in output_name else output_name % i packed_plist = atlas.dump_plist("%s%s" % (texture_file_name, self.texture_format), input_base_path, - self.atlas_format) + self.atlas_format, trim_sprite_names = self.trim_sprite_names) packed_image = atlas.dump_image(self.bg_color) if self.reduce_border_artifacts: diff --git a/docs/2_options.rst b/docs/2_options.rst index 6a38d57..a8ac1f8 100644 --- a/docs/2_options.rst +++ b/docs/2_options.rst @@ -95,4 +95,9 @@ atlas_ext ------- Forces the atlas to use this extension regardless of the format. -If not provided, the atlas will use the default extension for the chosen format. \ No newline at end of file +If not provided, the atlas will use the default extension for the chosen format. + +trim_sprite_names +----------------- + +Removes the file extension from the sprite names in the atlas. \ No newline at end of file diff --git a/test.py b/test.py index 5203742..07e6f48 100644 --- a/test.py +++ b/test.py @@ -23,9 +23,9 @@ def load_test_suite(): test_path = os.path.abspath(TEST_MODULE) files = os.listdir(test_path) - test_file_re = re.compile(TEST_CASE_NAME, re.IGNORECASE) - files = filter(test_file_re.match, files) - + # test_file_re = re.compile(TEST_CASE_NAME, re.IGNORECASE) + # files = filter(test_file_re.match, files) + files = [f for f in files if re.match(TEST_CASE_NAME, f, re.IGNORECASE)] module_names = map(lambda f: os.path.splitext(f)[0], files) modules = map(lambda x: __import__("%s.%s" % (TEST_MODULE, x), fromlist=[TEST_MODULE]), module_names) diff --git a/test_pack_image/output/test.plist b/test_pack_image/output/test.plist new file mode 100644 index 0000000..5cc9bd8 --- /dev/null +++ b/test_pack_image/output/test.plist @@ -0,0 +1,1294 @@ + + + + + frames + + path1/path1_1/32 + + frame + {{24,6},{4,7}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{4,7}} + sourceSize + {4,7} + + path1/path1_1/33 + + frame + {{2,8},{1,7}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{1,7}} + sourceSize + {2,7} + + path1/path1_1/34 + + frame + {{50,37},{3,3}} + offset + {0,2} + rotated + + sourceColorRect + {{0,0},{3,3}} + sourceSize + {4,7} + + path1/path1_1/35 + + frame + {{58,22},{5,5}} + offset + {0,0} + rotated + + sourceColorRect + {{0,1},{5,5}} + sourceSize + {6,7} + + path1/path1_1/36 + + frame + {{24,15},{4,7}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{4,7}} + sourceSize + {5,7} + + path1/path1_1/37 + + frame + {{58,2},{5,5}} + offset + {0,0} + rotated + + sourceColorRect + {{0,1},{5,5}} + sourceSize + {6,7} + + path1/path1_1/38 + + frame + {{2,11},{5,7}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{5,7}} + sourceSize + {6,7} + + path1/path1_1/39 + + frame + {{65,53},{2,3}} + offset + {0,2} + rotated + + sourceColorRect + {{0,0},{2,3}} + sourceSize + {3,7} + + path1/path1_1/40 + + frame + {{11,15},{2,7}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{2,7}} + sourceSize + {3,7} + + path1/path1_1/41 + + frame + {{2,18},{2,7}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{2,7}} + sourceSize + {3,7} + + path1/path1_1/42 + + frame + {{61,9},{5,5}} + offset + {0,0} + rotated + + sourceColorRect + {{0,1},{5,5}} + sourceSize + {6,7} + + path1/path1_1/43 + + frame + {{65,2},{5,5}} + offset + {0,0} + rotated + + sourceColorRect + {{0,1},{5,5}} + sourceSize + {6,7} + + path1/path1_1/44 + + frame + {{65,58},{2,3}} + offset + {0,-2} + rotated + + sourceColorRect + {{0,4},{2,3}} + sourceSize + {2,7} + + path1/path1_1/45 + + frame + {{69,53},{3,1}} + offset + {0,0} + rotated + + sourceColorRect + {{0,3},{3,1}} + sourceSize + {4,7} + + path1/path1_1/46 + + frame + {{59,53},{1,1}} + offset + {0,-2} + rotated + + sourceColorRect + {{0,5},{1,1}} + sourceSize + {2,7} + + path1/path1_1/47 + + frame + {{11,19},{3,7}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{3,7}} + sourceSize + {4,7} + + path1/path1_1/48 + + frame + {{20,36},{4,6}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{4,6}} + sourceSize + {5,7} + + path1/path1_1/49 + + frame + {{11,39},{2,6}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{2,6}} + sourceSize + {3,7} + + path2/path2_1/100 + + frame + {{19,42},{4,6}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{4,6}} + sourceSize + {5,7} + + path2/path2_1/101 + + frame + {{61,16},{4,5}} + offset + {0,0} + rotated + + sourceColorRect + {{0,1},{4,5}} + sourceSize + {5,7} + + path2/path2_1/102 + + frame + {{2,48},{2,6}} + offset + {0,0} + rotated + + sourceColorRect + {{1,0},{2,6}} + sourceSize + {4,7} + + path2/path2_1/103 + + frame + {{2,56},{4,6}} + offset + {0,0} + rotated + + sourceColorRect + {{0,1},{4,6}} + sourceSize + {5,7} + + path2/path2_1/104 + + frame + {{6,48},{4,6}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{4,6}} + sourceSize + {5,7} + + path2/path2_1/105 + + frame + {{27,42},{1,6}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{1,6}} + sourceSize + {2,7} + + path2/path2_1/106 + + frame + {{2,22},{2,7}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{2,7}} + sourceSize + {3,7} + + path2/path2_1/107 + + frame + {{10,56},{4,6}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{4,6}} + sourceSize + {5,7} + + path2/path2_1/108 + + frame + {{12,48},{1,6}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{1,6}} + sourceSize + {2,7} + + path2/path2_1/109 + + frame + {{11,24},{7,5}} + offset + {0,0} + rotated + + sourceColorRect + {{0,1},{7,5}} + sourceSize + {8,7} + + path2/path2_1/110 + + frame + {{58,56},{4,5}} + offset + {0,0} + rotated + + sourceColorRect + {{0,1},{4,5}} + sourceSize + {5,7} + + path2/path2_1/111 + + frame + {{59,46},{4,5}} + offset + {0,0} + rotated + + sourceColorRect + {{0,1},{4,5}} + sourceSize + {5,7} + + path2/path2_1/112 + + frame + {{15,50},{4,6}} + offset + {0,0} + rotated + + sourceColorRect + {{0,1},{4,6}} + sourceSize + {5,7} + + path2/path2_1/113 + + frame + {{18,56},{4,6}} + offset + {0,0} + rotated + + sourceColorRect + {{0,1},{4,6}} + sourceSize + {5,7} + + path2/path2_1/114 + + frame + {{2,43},{3,5}} + offset + {0,0} + rotated + + sourceColorRect + {{0,1},{3,5}} + sourceSize + {4,7} + + path2/path2_1/115 + + frame + {{9,43},{3,5}} + offset + {0,0} + rotated + + sourceColorRect + {{0,1},{3,5}} + sourceSize + {4,7} + + path2/path2_1/116 + + frame + {{23,48},{2,6}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{2,6}} + sourceSize + {3,7} + + path2/path2_1/117 + + frame + {{62,29},{4,5}} + offset + {0,0} + rotated + + sourceColorRect + {{0,1},{4,5}} + sourceSize + {5,7} + + path2/path2_1/118 + + frame + {{65,22},{4,5}} + offset + {0,0} + rotated + + sourceColorRect + {{0,1},{4,5}} + sourceSize + {5,7} + + path2/path2_1/119 + + frame + {{62,36},{5,5}} + offset + {0,0} + rotated + + sourceColorRect + {{0,1},{5,5}} + sourceSize + {6,7} + + path2/path2_1/120 + + frame + {{68,29},{5,5}} + offset + {0,0} + rotated + + sourceColorRect + {{0,1},{5,5}} + sourceSize + {6,7} + + path2/path2_1/121 + + frame + {{26,56},{4,6}} + offset + {0,0} + rotated + + sourceColorRect + {{0,1},{4,6}} + sourceSize + {5,7} + + path2/path2_1/122 + + frame + {{68,9},{4,5}} + offset + {0,0} + rotated + + sourceColorRect + {{0,1},{4,5}} + sourceSize + {5,7} + + path2/path2_1/123 + + frame + {{2,26},{3,7}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{3,7}} + sourceSize + {4,7} + + path2/path2_1/124 + + frame + {{2,31},{1,7}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{1,7}} + sourceSize + {2,7} + + path2/path2_1/125 + + frame + {{20,24},{3,7}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{3,7}} + sourceSize + {4,7} + + path2/path2_1/126 + + frame + {{30,22},{4,2}} + offset + {0,2} + rotated + + sourceColorRect + {{0,0},{4,2}} + sourceSize + {5,7} + + path2/path2_1/127 + + frame + {{72,2},{5,5}} + offset + {0,0} + rotated + + sourceColorRect + {{0,1},{5,5}} + sourceSize + {6,7} + + path2/path2_1/128 + + frame + {{14,2},{2,8}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{2,8}} + sourceSize + {2,8} + + path2/path2_1/129 + + frame + {{2,2},{4,10}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{4,10}} + sourceSize + {4,10} + + path2/path2_1/50 + + frame + {{27,50},{4,6}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{4,6}} + sourceSize + {5,7} + + path2/path2_1/51 + + frame + {{34,56},{4,6}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{4,6}} + sourceSize + {5,7} + + path2/path2_1/52 + + frame + {{28,36},{4,6}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{4,6}} + sourceSize + {5,7} + + path2/path2_1/53 + + frame + {{30,42},{4,6}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{4,6}} + sourceSize + {5,7} + + path2/path2_1/54 + + frame + {{35,50},{4,6}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{4,6}} + sourceSize + {5,7} + + path2/path2_1/55 + + frame + {{42,56},{4,6}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{4,6}} + sourceSize + {5,7} + + path2/path2_1/56 + + frame + {{50,2},{4,6}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{4,6}} + sourceSize + {5,7} + + path2/path2_1/57 + + frame + {{43,2},{4,6}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{4,6}} + sourceSize + {5,7} + + path2/path2_1/58 + + frame + {{62,43},{1,5}} + offset + {0,0} + rotated + + sourceColorRect + {{0,1},{1,5}} + sourceSize + {2,7} + + path2/path2_1/59 + + frame + {{24,2},{2,6}} + offset + {0,0} + rotated + + sourceColorRect + {{0,1},{2,6}} + sourceSize + {2,7} + + path2/path2_1/60 + + frame + {{50,30},{3,5}} + offset + {0,0} + rotated + + sourceColorRect + {{0,1},{3,5}} + sourceSize + {4,7} + + path2/path2_1/61 + + frame + {{75,16},{4,3}} + offset + {0,0} + rotated + + sourceColorRect + {{0,2},{4,3}} + sourceSize + {5,7} + + path2/path2_1/62 + + frame + {{68,16},{3,5}} + offset + {0,0} + rotated + + sourceColorRect + {{0,1},{3,5}} + sourceSize + {4,7} + + path2/path2_1/63 + + frame + {{36,2},{4,6}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{4,6}} + sourceSize + {4,7} + + path2/path2_1/64 + + frame + {{14,6},{8,7}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{8,7}} + sourceSize + {9,7} + + path2/path2_1/65 + + frame + {{30,6},{4,6}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{4,6}} + sourceSize + {5,7} + + path2/path2_1/66 + + frame + {{36,10},{4,6}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{4,6}} + sourceSize + {5,7} + + path2/path2_1/67 + + frame + {{30,14},{4,6}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{4,6}} + sourceSize + {5,7} + + path2/path2_1/68 + + frame + {{50,8},{4,6}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{4,6}} + sourceSize + {5,7} + + path2/path2_1/69 + + frame + {{42,10},{4,6}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{4,6}} + sourceSize + {5,7} + + path2/path2_1/70 + + frame + {{50,14},{4,6}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{4,6}} + sourceSize + {5,7} + + path2/path2_1/71 + + frame + {{42,16},{4,6}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{4,6}} + sourceSize + {5,7} + + path2/path2_1/72 + + frame + {{36,18},{4,6}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{4,6}} + sourceSize + {5,7} + + path2/path2_1/73 + + frame + {{58,14},{1,6}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{1,6}} + sourceSize + {2,7} + + path2/path2_1/74 + + frame + {{50,20},{2,6}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{2,6}} + sourceSize + {3,7} + + path2/path2_1/75 + + frame + {{42,22},{4,6}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{4,6}} + sourceSize + {5,7} + + path2/path2_1/76 + + frame + {{36,26},{4,6}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{4,6}} + sourceSize + {5,7} + + path2/path2_1/77 + + frame + {{29,26},{5,6}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{5,6}} + sourceSize + {6,7} + + path2/path2_1/78 + + frame + {{50,24},{4,6}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{4,6}} + sourceSize + {5,7} + + path2/path2_1/79 + + frame + {{42,28},{5,6}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{5,6}} + sourceSize + {6,7} + + path2/path2_1/80 + + frame + {{36,34},{4,6}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{4,6}} + sourceSize + {5,7} + + path2/path2_1/81 + + frame + {{20,29},{5,7}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{5,7}} + sourceSize + {6,7} + + path2/path2_1/82 + + frame + {{36,42},{4,6}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{4,6}} + sourceSize + {5,7} + + path2/path2_1/83 + + frame + {{42,42},{4,6}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{4,6}} + sourceSize + {5,7} + + path2/path2_1/84 + + frame + {{42,35},{5,6}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{5,6}} + sourceSize + {6,7} + + path2/path2_1/85 + + frame + {{43,50},{4,6}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{4,6}} + sourceSize + {5,7} + + path2/path2_1/86 + + frame + {{48,42},{5,6}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{5,6}} + sourceSize + {6,7} + + path2/path2_1/87 + + frame + {{11,31},{7,6}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{7,6}} + sourceSize + {8,7} + + path2/path2_1/88 + + frame + {{55,30},{5,6}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{5,6}} + sourceSize + {6,7} + + path2/path2_1/89 + + frame + {{55,38},{5,6}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{5,6}} + sourceSize + {6,7} + + path2/path2_1/90 + + frame + {{50,56},{4,6}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{4,6}} + sourceSize + {5,7} + + path2/path2_1/91 + + frame + {{2,34},{2,7}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{2,7}} + sourceSize + {3,7} + + path2/path2_1/92 + + frame + {{2,38},{3,7}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{3,7}} + sourceSize + {4,7} + + path2/path2_1/93 + + frame + {{20,15},{2,7}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{2,7}} + sourceSize + {3,7} + + path2/path2_1/94 + + frame + {{74,9},{5,3}} + offset + {0,2} + rotated + + sourceColorRect + {{0,0},{5,3}} + sourceSize + {6,7} + + path2/path2_1/95 + + frame + {{16,43},{5,1}} + offset + {0,-3} + rotated + + sourceColorRect + {{0,6},{5,1}} + sourceSize + {6,7} + + path2/path2_1/96 + + frame + {{70,58},{2,3}} + offset + {0,2} + rotated + + sourceColorRect + {{0,0},{2,3}} + sourceSize + {3,7} + + path2/path2_1/97 + + frame + {{71,21},{4,5}} + offset + {0,0} + rotated + + sourceColorRect + {{0,1},{4,5}} + sourceSize + {5,7} + + path2/path2_1/98 + + frame + {{51,50},{4,6}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{4,6}} + sourceSize + {5,7} + + path2/path2_1/99 + + frame + {{65,46},{4,5}} + offset + {0,0} + rotated + + sourceColorRect + {{0,1},{4,5}} + sourceSize + {5,7} + + + metadata + + format + 2 + realTextureFileName + test_pack_image/output/test.png + size + {128,64} + textureFileName + test_pack_image/output/test.png + + + diff --git a/test_pack_image/output/test.png b/test_pack_image/output/test.png new file mode 100644 index 0000000..f190dd1 Binary files /dev/null and b/test_pack_image/output/test.png differ diff --git a/test_pack_image/path1/path1_1/32.png b/test_pack_image/path1/path1_1/32.png new file mode 100644 index 0000000..a2b22c0 Binary files /dev/null and b/test_pack_image/path1/path1_1/32.png differ diff --git a/test_pack_image/path1/path1_1/33.png b/test_pack_image/path1/path1_1/33.png new file mode 100644 index 0000000..1df704f Binary files /dev/null and b/test_pack_image/path1/path1_1/33.png differ diff --git a/test_pack_image/path1/path1_1/34.png b/test_pack_image/path1/path1_1/34.png new file mode 100644 index 0000000..feeeb01 Binary files /dev/null and b/test_pack_image/path1/path1_1/34.png differ diff --git a/test_pack_image/path1/path1_1/35.png b/test_pack_image/path1/path1_1/35.png new file mode 100644 index 0000000..19c0242 Binary files /dev/null and b/test_pack_image/path1/path1_1/35.png differ diff --git a/test_pack_image/path1/path1_1/36.png b/test_pack_image/path1/path1_1/36.png new file mode 100644 index 0000000..c5ef84a Binary files /dev/null and b/test_pack_image/path1/path1_1/36.png differ diff --git a/test_pack_image/path1/path1_1/37.png b/test_pack_image/path1/path1_1/37.png new file mode 100644 index 0000000..040cfee Binary files /dev/null and b/test_pack_image/path1/path1_1/37.png differ diff --git a/test_pack_image/path1/path1_1/38.png b/test_pack_image/path1/path1_1/38.png new file mode 100644 index 0000000..8f6ed88 Binary files /dev/null and b/test_pack_image/path1/path1_1/38.png differ diff --git a/test_pack_image/path1/path1_1/39.png b/test_pack_image/path1/path1_1/39.png new file mode 100644 index 0000000..895768a Binary files /dev/null and b/test_pack_image/path1/path1_1/39.png differ diff --git a/test_pack_image/path1/path1_1/40.png b/test_pack_image/path1/path1_1/40.png new file mode 100644 index 0000000..c7eb455 Binary files /dev/null and b/test_pack_image/path1/path1_1/40.png differ diff --git a/test_pack_image/path1/path1_1/41.png b/test_pack_image/path1/path1_1/41.png new file mode 100644 index 0000000..a390ac2 Binary files /dev/null and b/test_pack_image/path1/path1_1/41.png differ diff --git a/test_pack_image/path1/path1_1/42.png b/test_pack_image/path1/path1_1/42.png new file mode 100644 index 0000000..0cb39c0 Binary files /dev/null and b/test_pack_image/path1/path1_1/42.png differ diff --git a/test_pack_image/path1/path1_1/43.png b/test_pack_image/path1/path1_1/43.png new file mode 100644 index 0000000..9437a4b Binary files /dev/null and b/test_pack_image/path1/path1_1/43.png differ diff --git a/test_pack_image/path1/path1_1/44.png b/test_pack_image/path1/path1_1/44.png new file mode 100644 index 0000000..77212d2 Binary files /dev/null and b/test_pack_image/path1/path1_1/44.png differ diff --git a/test_pack_image/path1/path1_1/45.png b/test_pack_image/path1/path1_1/45.png new file mode 100644 index 0000000..294c81c Binary files /dev/null and b/test_pack_image/path1/path1_1/45.png differ diff --git a/test_pack_image/path1/path1_1/46.png b/test_pack_image/path1/path1_1/46.png new file mode 100644 index 0000000..5e33ef1 Binary files /dev/null and b/test_pack_image/path1/path1_1/46.png differ diff --git a/test_pack_image/path1/path1_1/47.png b/test_pack_image/path1/path1_1/47.png new file mode 100644 index 0000000..38d132f Binary files /dev/null and b/test_pack_image/path1/path1_1/47.png differ diff --git a/test_pack_image/path1/path1_1/48.png b/test_pack_image/path1/path1_1/48.png new file mode 100644 index 0000000..92368a8 Binary files /dev/null and b/test_pack_image/path1/path1_1/48.png differ diff --git a/test_pack_image/path1/path1_1/49.png b/test_pack_image/path1/path1_1/49.png new file mode 100644 index 0000000..4cb27f4 Binary files /dev/null and b/test_pack_image/path1/path1_1/49.png differ diff --git a/test_pack_image/path2/path2_1/100.png b/test_pack_image/path2/path2_1/100.png new file mode 100644 index 0000000..9f31068 Binary files /dev/null and b/test_pack_image/path2/path2_1/100.png differ diff --git a/test_pack_image/path2/path2_1/101.png b/test_pack_image/path2/path2_1/101.png new file mode 100644 index 0000000..4e3c603 Binary files /dev/null and b/test_pack_image/path2/path2_1/101.png differ diff --git a/test_pack_image/path2/path2_1/102.png b/test_pack_image/path2/path2_1/102.png new file mode 100644 index 0000000..95c76e2 Binary files /dev/null and b/test_pack_image/path2/path2_1/102.png differ diff --git a/test_pack_image/path2/path2_1/103.png b/test_pack_image/path2/path2_1/103.png new file mode 100644 index 0000000..455e7d9 Binary files /dev/null and b/test_pack_image/path2/path2_1/103.png differ diff --git a/test_pack_image/path2/path2_1/104.png b/test_pack_image/path2/path2_1/104.png new file mode 100644 index 0000000..7b88021 Binary files /dev/null and b/test_pack_image/path2/path2_1/104.png differ diff --git a/test_pack_image/path2/path2_1/105.png b/test_pack_image/path2/path2_1/105.png new file mode 100644 index 0000000..fef24da Binary files /dev/null and b/test_pack_image/path2/path2_1/105.png differ diff --git a/test_pack_image/path2/path2_1/106.png b/test_pack_image/path2/path2_1/106.png new file mode 100644 index 0000000..88ffe0f Binary files /dev/null and b/test_pack_image/path2/path2_1/106.png differ diff --git a/test_pack_image/path2/path2_1/107.png b/test_pack_image/path2/path2_1/107.png new file mode 100644 index 0000000..0bb3fe8 Binary files /dev/null and b/test_pack_image/path2/path2_1/107.png differ diff --git a/test_pack_image/path2/path2_1/108.png b/test_pack_image/path2/path2_1/108.png new file mode 100644 index 0000000..d12022e Binary files /dev/null and b/test_pack_image/path2/path2_1/108.png differ diff --git a/test_pack_image/path2/path2_1/109.png b/test_pack_image/path2/path2_1/109.png new file mode 100644 index 0000000..c6ceafb Binary files /dev/null and b/test_pack_image/path2/path2_1/109.png differ diff --git a/test_pack_image/path2/path2_1/110.png b/test_pack_image/path2/path2_1/110.png new file mode 100644 index 0000000..bac43ae Binary files /dev/null and b/test_pack_image/path2/path2_1/110.png differ diff --git a/test_pack_image/path2/path2_1/111.png b/test_pack_image/path2/path2_1/111.png new file mode 100644 index 0000000..e59615d Binary files /dev/null and b/test_pack_image/path2/path2_1/111.png differ diff --git a/test_pack_image/path2/path2_1/112.png b/test_pack_image/path2/path2_1/112.png new file mode 100644 index 0000000..94adcc5 Binary files /dev/null and b/test_pack_image/path2/path2_1/112.png differ diff --git a/test_pack_image/path2/path2_1/113.png b/test_pack_image/path2/path2_1/113.png new file mode 100644 index 0000000..1cb3584 Binary files /dev/null and b/test_pack_image/path2/path2_1/113.png differ diff --git a/test_pack_image/path2/path2_1/114.png b/test_pack_image/path2/path2_1/114.png new file mode 100644 index 0000000..ad15a33 Binary files /dev/null and b/test_pack_image/path2/path2_1/114.png differ diff --git a/test_pack_image/path2/path2_1/115.png b/test_pack_image/path2/path2_1/115.png new file mode 100644 index 0000000..536af35 Binary files /dev/null and b/test_pack_image/path2/path2_1/115.png differ diff --git a/test_pack_image/path2/path2_1/116.png b/test_pack_image/path2/path2_1/116.png new file mode 100644 index 0000000..e74fe9f Binary files /dev/null and b/test_pack_image/path2/path2_1/116.png differ diff --git a/test_pack_image/path2/path2_1/117.png b/test_pack_image/path2/path2_1/117.png new file mode 100644 index 0000000..41c30a2 Binary files /dev/null and b/test_pack_image/path2/path2_1/117.png differ diff --git a/test_pack_image/path2/path2_1/118.png b/test_pack_image/path2/path2_1/118.png new file mode 100644 index 0000000..f460f2e Binary files /dev/null and b/test_pack_image/path2/path2_1/118.png differ diff --git a/test_pack_image/path2/path2_1/119.png b/test_pack_image/path2/path2_1/119.png new file mode 100644 index 0000000..7bd6b97 Binary files /dev/null and b/test_pack_image/path2/path2_1/119.png differ diff --git a/test_pack_image/path2/path2_1/120.png b/test_pack_image/path2/path2_1/120.png new file mode 100644 index 0000000..701aa94 Binary files /dev/null and b/test_pack_image/path2/path2_1/120.png differ diff --git a/test_pack_image/path2/path2_1/121.png b/test_pack_image/path2/path2_1/121.png new file mode 100644 index 0000000..42d4f02 Binary files /dev/null and b/test_pack_image/path2/path2_1/121.png differ diff --git a/test_pack_image/path2/path2_1/122.png b/test_pack_image/path2/path2_1/122.png new file mode 100644 index 0000000..d62b74a Binary files /dev/null and b/test_pack_image/path2/path2_1/122.png differ diff --git a/test_pack_image/path2/path2_1/123.png b/test_pack_image/path2/path2_1/123.png new file mode 100644 index 0000000..7e70609 Binary files /dev/null and b/test_pack_image/path2/path2_1/123.png differ diff --git a/test_pack_image/path2/path2_1/124.png b/test_pack_image/path2/path2_1/124.png new file mode 100644 index 0000000..ff7df3c Binary files /dev/null and b/test_pack_image/path2/path2_1/124.png differ diff --git a/test_pack_image/path2/path2_1/125.png b/test_pack_image/path2/path2_1/125.png new file mode 100644 index 0000000..b1bef0a Binary files /dev/null and b/test_pack_image/path2/path2_1/125.png differ diff --git a/test_pack_image/path2/path2_1/126.png b/test_pack_image/path2/path2_1/126.png new file mode 100644 index 0000000..d372972 Binary files /dev/null and b/test_pack_image/path2/path2_1/126.png differ diff --git a/test_pack_image/path2/path2_1/127.png b/test_pack_image/path2/path2_1/127.png new file mode 100644 index 0000000..29328d8 Binary files /dev/null and b/test_pack_image/path2/path2_1/127.png differ diff --git a/test_pack_image/path2/path2_1/128.png b/test_pack_image/path2/path2_1/128.png new file mode 100644 index 0000000..b78a1ef Binary files /dev/null and b/test_pack_image/path2/path2_1/128.png differ diff --git a/test_pack_image/path2/path2_1/129.png b/test_pack_image/path2/path2_1/129.png new file mode 100644 index 0000000..afe03da Binary files /dev/null and b/test_pack_image/path2/path2_1/129.png differ diff --git a/test_pack_image/path2/path2_1/50.png b/test_pack_image/path2/path2_1/50.png new file mode 100644 index 0000000..ff56400 Binary files /dev/null and b/test_pack_image/path2/path2_1/50.png differ diff --git a/test_pack_image/path2/path2_1/51.png b/test_pack_image/path2/path2_1/51.png new file mode 100644 index 0000000..efcde48 Binary files /dev/null and b/test_pack_image/path2/path2_1/51.png differ diff --git a/test_pack_image/path2/path2_1/52.png b/test_pack_image/path2/path2_1/52.png new file mode 100644 index 0000000..14d9f4a Binary files /dev/null and b/test_pack_image/path2/path2_1/52.png differ diff --git a/test_pack_image/path2/path2_1/53.png b/test_pack_image/path2/path2_1/53.png new file mode 100644 index 0000000..db7f37b Binary files /dev/null and b/test_pack_image/path2/path2_1/53.png differ diff --git a/test_pack_image/path2/path2_1/54.png b/test_pack_image/path2/path2_1/54.png new file mode 100644 index 0000000..7cb5949 Binary files /dev/null and b/test_pack_image/path2/path2_1/54.png differ diff --git a/test_pack_image/path2/path2_1/55.png b/test_pack_image/path2/path2_1/55.png new file mode 100644 index 0000000..7a46031 Binary files /dev/null and b/test_pack_image/path2/path2_1/55.png differ diff --git a/test_pack_image/path2/path2_1/56.png b/test_pack_image/path2/path2_1/56.png new file mode 100644 index 0000000..de8dfb3 Binary files /dev/null and b/test_pack_image/path2/path2_1/56.png differ diff --git a/test_pack_image/path2/path2_1/57.png b/test_pack_image/path2/path2_1/57.png new file mode 100644 index 0000000..91ff710 Binary files /dev/null and b/test_pack_image/path2/path2_1/57.png differ diff --git a/test_pack_image/path2/path2_1/58.png b/test_pack_image/path2/path2_1/58.png new file mode 100644 index 0000000..631210b Binary files /dev/null and b/test_pack_image/path2/path2_1/58.png differ diff --git a/test_pack_image/path2/path2_1/59.png b/test_pack_image/path2/path2_1/59.png new file mode 100644 index 0000000..1854948 Binary files /dev/null and b/test_pack_image/path2/path2_1/59.png differ diff --git a/test_pack_image/path2/path2_1/60.png b/test_pack_image/path2/path2_1/60.png new file mode 100644 index 0000000..45fa7b8 Binary files /dev/null and b/test_pack_image/path2/path2_1/60.png differ diff --git a/test_pack_image/path2/path2_1/61.png b/test_pack_image/path2/path2_1/61.png new file mode 100644 index 0000000..371f9a0 Binary files /dev/null and b/test_pack_image/path2/path2_1/61.png differ diff --git a/test_pack_image/path2/path2_1/62.png b/test_pack_image/path2/path2_1/62.png new file mode 100644 index 0000000..f989213 Binary files /dev/null and b/test_pack_image/path2/path2_1/62.png differ diff --git a/test_pack_image/path2/path2_1/63.png b/test_pack_image/path2/path2_1/63.png new file mode 100644 index 0000000..25423ee Binary files /dev/null and b/test_pack_image/path2/path2_1/63.png differ diff --git a/test_pack_image/path2/path2_1/64.png b/test_pack_image/path2/path2_1/64.png new file mode 100644 index 0000000..48189c4 Binary files /dev/null and b/test_pack_image/path2/path2_1/64.png differ diff --git a/test_pack_image/path2/path2_1/65.png b/test_pack_image/path2/path2_1/65.png new file mode 100644 index 0000000..d7a0102 Binary files /dev/null and b/test_pack_image/path2/path2_1/65.png differ diff --git a/test_pack_image/path2/path2_1/66.png b/test_pack_image/path2/path2_1/66.png new file mode 100644 index 0000000..905621d Binary files /dev/null and b/test_pack_image/path2/path2_1/66.png differ diff --git a/test_pack_image/path2/path2_1/67.png b/test_pack_image/path2/path2_1/67.png new file mode 100644 index 0000000..7a9f73c Binary files /dev/null and b/test_pack_image/path2/path2_1/67.png differ diff --git a/test_pack_image/path2/path2_1/68.png b/test_pack_image/path2/path2_1/68.png new file mode 100644 index 0000000..4bc752e Binary files /dev/null and b/test_pack_image/path2/path2_1/68.png differ diff --git a/test_pack_image/path2/path2_1/69.png b/test_pack_image/path2/path2_1/69.png new file mode 100644 index 0000000..3c51c8c Binary files /dev/null and b/test_pack_image/path2/path2_1/69.png differ diff --git a/test_pack_image/path2/path2_1/70.png b/test_pack_image/path2/path2_1/70.png new file mode 100644 index 0000000..b9eb3fe Binary files /dev/null and b/test_pack_image/path2/path2_1/70.png differ diff --git a/test_pack_image/path2/path2_1/71.png b/test_pack_image/path2/path2_1/71.png new file mode 100644 index 0000000..df6ed33 Binary files /dev/null and b/test_pack_image/path2/path2_1/71.png differ diff --git a/test_pack_image/path2/path2_1/72.png b/test_pack_image/path2/path2_1/72.png new file mode 100644 index 0000000..4b5b393 Binary files /dev/null and b/test_pack_image/path2/path2_1/72.png differ diff --git a/test_pack_image/path2/path2_1/73.png b/test_pack_image/path2/path2_1/73.png new file mode 100644 index 0000000..d12022e Binary files /dev/null and b/test_pack_image/path2/path2_1/73.png differ diff --git a/test_pack_image/path2/path2_1/74.png b/test_pack_image/path2/path2_1/74.png new file mode 100644 index 0000000..3a0581a Binary files /dev/null and b/test_pack_image/path2/path2_1/74.png differ diff --git a/test_pack_image/path2/path2_1/75.png b/test_pack_image/path2/path2_1/75.png new file mode 100644 index 0000000..21a4678 Binary files /dev/null and b/test_pack_image/path2/path2_1/75.png differ diff --git a/test_pack_image/path2/path2_1/76.png b/test_pack_image/path2/path2_1/76.png new file mode 100644 index 0000000..1b2250b Binary files /dev/null and b/test_pack_image/path2/path2_1/76.png differ diff --git a/test_pack_image/path2/path2_1/77.png b/test_pack_image/path2/path2_1/77.png new file mode 100644 index 0000000..03727ff Binary files /dev/null and b/test_pack_image/path2/path2_1/77.png differ diff --git a/test_pack_image/path2/path2_1/78.png b/test_pack_image/path2/path2_1/78.png new file mode 100644 index 0000000..a72355d Binary files /dev/null and b/test_pack_image/path2/path2_1/78.png differ diff --git a/test_pack_image/path2/path2_1/79.png b/test_pack_image/path2/path2_1/79.png new file mode 100644 index 0000000..b3b4ef7 Binary files /dev/null and b/test_pack_image/path2/path2_1/79.png differ diff --git a/test_pack_image/path2/path2_1/80.png b/test_pack_image/path2/path2_1/80.png new file mode 100644 index 0000000..045972f Binary files /dev/null and b/test_pack_image/path2/path2_1/80.png differ diff --git a/test_pack_image/path2/path2_1/81.png b/test_pack_image/path2/path2_1/81.png new file mode 100644 index 0000000..3a9f3b8 Binary files /dev/null and b/test_pack_image/path2/path2_1/81.png differ diff --git a/test_pack_image/path2/path2_1/82.png b/test_pack_image/path2/path2_1/82.png new file mode 100644 index 0000000..6e715e9 Binary files /dev/null and b/test_pack_image/path2/path2_1/82.png differ diff --git a/test_pack_image/path2/path2_1/83.png b/test_pack_image/path2/path2_1/83.png new file mode 100644 index 0000000..9cb2d37 Binary files /dev/null and b/test_pack_image/path2/path2_1/83.png differ diff --git a/test_pack_image/path2/path2_1/84.png b/test_pack_image/path2/path2_1/84.png new file mode 100644 index 0000000..654852e Binary files /dev/null and b/test_pack_image/path2/path2_1/84.png differ diff --git a/test_pack_image/path2/path2_1/85.png b/test_pack_image/path2/path2_1/85.png new file mode 100644 index 0000000..88fa2c1 Binary files /dev/null and b/test_pack_image/path2/path2_1/85.png differ diff --git a/test_pack_image/path2/path2_1/86.png b/test_pack_image/path2/path2_1/86.png new file mode 100644 index 0000000..9f0d778 Binary files /dev/null and b/test_pack_image/path2/path2_1/86.png differ diff --git a/test_pack_image/path2/path2_1/87.png b/test_pack_image/path2/path2_1/87.png new file mode 100644 index 0000000..05c42f2 Binary files /dev/null and b/test_pack_image/path2/path2_1/87.png differ diff --git a/test_pack_image/path2/path2_1/88.png b/test_pack_image/path2/path2_1/88.png new file mode 100644 index 0000000..0194950 Binary files /dev/null and b/test_pack_image/path2/path2_1/88.png differ diff --git a/test_pack_image/path2/path2_1/89.png b/test_pack_image/path2/path2_1/89.png new file mode 100644 index 0000000..c39f931 Binary files /dev/null and b/test_pack_image/path2/path2_1/89.png differ diff --git a/test_pack_image/path2/path2_1/90.png b/test_pack_image/path2/path2_1/90.png new file mode 100644 index 0000000..dc41f38 Binary files /dev/null and b/test_pack_image/path2/path2_1/90.png differ diff --git a/test_pack_image/path2/path2_1/91.png b/test_pack_image/path2/path2_1/91.png new file mode 100644 index 0000000..04e116a Binary files /dev/null and b/test_pack_image/path2/path2_1/91.png differ diff --git a/test_pack_image/path2/path2_1/92.png b/test_pack_image/path2/path2_1/92.png new file mode 100644 index 0000000..66739de Binary files /dev/null and b/test_pack_image/path2/path2_1/92.png differ diff --git a/test_pack_image/path2/path2_1/93.png b/test_pack_image/path2/path2_1/93.png new file mode 100644 index 0000000..53ec360 Binary files /dev/null and b/test_pack_image/path2/path2_1/93.png differ diff --git a/test_pack_image/path2/path2_1/94.png b/test_pack_image/path2/path2_1/94.png new file mode 100644 index 0000000..3962eed Binary files /dev/null and b/test_pack_image/path2/path2_1/94.png differ diff --git a/test_pack_image/path2/path2_1/95.png b/test_pack_image/path2/path2_1/95.png new file mode 100644 index 0000000..c67ef2f Binary files /dev/null and b/test_pack_image/path2/path2_1/95.png differ diff --git a/test_pack_image/path2/path2_1/96.png b/test_pack_image/path2/path2_1/96.png new file mode 100644 index 0000000..4c73656 Binary files /dev/null and b/test_pack_image/path2/path2_1/96.png differ diff --git a/test_pack_image/path2/path2_1/97.png b/test_pack_image/path2/path2_1/97.png new file mode 100644 index 0000000..a7ec30f Binary files /dev/null and b/test_pack_image/path2/path2_1/97.png differ diff --git a/test_pack_image/path2/path2_1/98.png b/test_pack_image/path2/path2_1/98.png new file mode 100644 index 0000000..8f4807c Binary files /dev/null and b/test_pack_image/path2/path2_1/98.png differ diff --git a/test_pack_image/path2/path2_1/99.png b/test_pack_image/path2/path2_1/99.png new file mode 100644 index 0000000..feca903 Binary files /dev/null and b/test_pack_image/path2/path2_1/99.png differ diff --git a/tests/TestPack.py b/tests/TestPack.py new file mode 100644 index 0000000..e00b700 --- /dev/null +++ b/tests/TestPack.py @@ -0,0 +1,33 @@ +''' + # @ Author: hui.xie + # @ Create Time: 2025-09-05 16:02:21 + # @ Modified by: hui.xie + # @ Modified time: 2025-09-05 16:05:34 + # @ Description: + ''' + + +import unittest +from PyTexturePacker import Packer + +TEST_IMAGE_DIR = 'test_pack_image' +TEST_PLIST_DIR = 'test_pack_image/output/test' + +class TestRect(unittest.TestCase): + def setUp(self): + self.test_dir = TEST_IMAGE_DIR + self.test_out = TEST_PLIST_DIR + + def tearDown(self): + pass + + def test_pack(self): + packer = Packer.create(max_width=4096, max_height=4096, bg_color=0x00000000, border_padding=2, + shape_padding=2, extrude=0, trim_mode=1, enable_rotated=True, trim_sprite_names=True) + print('Packing textures...') + packer.pack(self.test_dir, self.test_out, input_base_path=self.test_dir) + print('Packing completed.') + + +if __name__ == '__main__': + unittest.main() \ No newline at end of file