-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
157 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
from ._texturizing import img2tex | ||
from ._texturizing import file_to_seamless, image_to_seamless, img2tex | ||
from ._cli import cli |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
from PIL import Image | ||
|
||
# preventing Image.DecompressionBombError: Image size (324000000 pixels) | ||
# exceeds limit of 178956970 pixels, could be decompression bomb DOS attack. | ||
# We just open a large file and are not afraid of it | ||
Image.MAX_IMAGE_PIXELS = None | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
__version__ = "1.0.6" | ||
__version__ = "1.1.0" | ||
|
||
__copyright__ = "(c) Artsiom iG <[email protected]>" | ||
__copyright__ = "(c) Artem iG <[email protected]>" | ||
__license__ = "MIT" | ||
__build_timestamp__ = "2022-10-12 05:30:19" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from PIL import Image | ||
from img2texture import image_to_seamless | ||
|
||
# load PIL image | ||
src_image = Image.open("/path/to/source.png") | ||
|
||
# convert to seamless PIL image | ||
result_image = image_to_seamless(src_image, overlap=0.1) | ||
|
||
# save | ||
result_image.save("/path/to/result.png") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,11 +23,12 @@ def load_module_dict(filename: str) -> dict: | |
name=name, | ||
version=constants['__version__'], | ||
|
||
author="Artsiom iG", | ||
author="Artёm iG", | ||
author_email="[email protected]", | ||
url='https://github.com/rtmigo/img2texture#readme', | ||
|
||
packages=find_packages(include=[name, f'{name}.*']), | ||
package_data={name: ["py.typed"]}, | ||
|
||
python_requires='>=3.7, <4', | ||
install_requires=["pillow>=9.2, <10"], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# SPDX-FileCopyrightText: (c) 2021 Artёm iG <github.com/rtmigo> | ||
# SPDX-License-Identifier: MIT | ||
|
||
|
||
import unittest | ||
from pathlib import Path | ||
|
||
from PIL import Image | ||
|
||
from img2texture._texturizing import horizontal_gradient_256_scaled, Mixer, \ | ||
file_to_seamless | ||
from img2texture._tiling import tile | ||
from tests.helpers import temp_file_path, file_md5 | ||
|
||
|
||
class TestGradient(unittest.TestCase): | ||
def test(self): | ||
w = 100 | ||
h = 50 | ||
result = horizontal_gradient_256_scaled((100, 50)) | ||
self.assertEqual(result.size[0], w) | ||
self.assertEqual(result.size[1], h) | ||
|
||
outfile = temp_file_path("gradient_h_1.png") | ||
result.save(outfile) | ||
self.assertEqual(file_md5(outfile), 'b135a054bc325a37df404b141f512567') | ||
|
||
|
||
class TestToSeamless(unittest.TestCase): | ||
def test_overlap_tuple(self): | ||
src = Path(__file__).parent / "data" / "sand.png" | ||
dst = temp_file_path("sand-tx-tuple.png") | ||
dst_tiled = temp_file_path("sand-tx-tuple-tiled.png") | ||
|
||
file_to_seamless(src, dst, overlap=(0.4, 0.3)) | ||
tile(dst, dst_tiled) | ||
|
||
# without RGB conversion it was c9c4d278498050e99c1df3994efc3bcd | ||
self.assertEqual(file_md5(dst), '696749d1337dc3d9e4021e9b8852a6e1') | ||
|
||
def test_overlap_float(self): | ||
src = Path(__file__).parent / "data" / "sand.png" | ||
dst = temp_file_path("sand-tx-float.png") | ||
dst_tiled = temp_file_path("sand-tx-float-tiled.png") | ||
|
||
file_to_seamless(src, dst, overlap=0.4) | ||
tile(dst, dst_tiled) | ||
|
||
# without RGB conversion it was c9c4d278498050e99c1df3994efc3bcd | ||
self.assertEqual(file_md5(dst), 'c957847053bc9f7747369f8a3ae091d2') | ||
|
||
|
||
if __name__ == "__main__": | ||
# TestGradient().test() | ||
TestToSeamless().test_overlap_tuple() |