rtmigo/img2texture

[Request] Non CLI Usage

WASasquatch opened this issue · 2 comments

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.

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.

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

https://github.com/WASasquatch/img2texture