Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Request] Non CLI Usage #1

Closed
WASasquatch opened this issue Apr 1, 2023 · 2 comments
Closed

[Request] Non CLI Usage #1

WASasquatch opened this issue Apr 1, 2023 · 2 comments

Comments

@WASasquatch
Copy link

WASasquatch commented Apr 1, 2023

There is a real lack of seamless texture generators for Python, especially ones that don't destroy the original image through warping and internal repeating.

Is there any chance you could provide a import route for running the functions? Currently there is only CLI which is useful programmatically without obtrusive system exec calls.

Additionally, for my current workflow, the IO time to save/load images kills the real-time effect. Seems I could get [low but decent] frame-rate if the processing wasn't utilizing disk writing and reading.

@WASasquatch
Copy link
Author

I partly answered my question. I can use it without exec calls as follows

import os
from pathlib import Path

import img2texture._constants as constants
from img2texture import img2tex
from img2texture._tiling import tile

def tile_filename(texture: Path) -> Path:
    basename = os.path.basename(texture)
    basename = basename.rpartition('.')[0]
    basename += "_2x2.jpg"
    return os.path.join(os.path.dirname(texture), basename)

source = '/content/input_.png'
target = '/content/output.png'

img2tex(source, target, pct=0.5)

tile(target, tile_filename(source), horizontal=2, vertical=2)

Just not without saving and opening the files.

@WASasquatch
Copy link
Author

Forked and edited my own version that can optionally accept a PIL image, and return one.

https://github.com/WASasquatch/img2texture

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant