Skip to content

Commit 59bf025

Browse files
committed
fix #20 rework filename guessing. stable now
1 parent 9a869db commit 59bf025

File tree

1 file changed

+3
-31
lines changed

1 file changed

+3
-31
lines changed

txt2vectorgfx.py

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -98,42 +98,14 @@ def run(self, p, poUseColor,poFormat, poOpaque, poTight, poKeepPnm, poThreshold,
9898
# Add the prompt from above
9999
p.prompt += StyleDict[poUseColor]
100100

101-
# not yet
102-
# p.cfg_scale=BASE_SCALE
103-
# p.steps = BASE_STEPS
104-
105-
images = []
106101
proc = process_images(p)
107-
images += proc.images
108-
109-
# unfortunately the concrete file name is nontrivial using increment counter etc, so we have to reverse-guess the last stored images by changetime
110-
folder = p.outpath_samples
111-
112-
if opts.save_to_dirs:
113-
folder = glob.glob(p.outpath_samples+"/*")
114-
folder = max(folder, key=os.path.getctime)
115-
116-
tobeglobbed = folder+"/*."+opts.samples_format
117-
files = glob.glob(tobeglobbed)
118-
119-
if (len(files) < 1) :
120-
print("Txt2Vector: image file not yet written, waiting two seconds for filesystem...")
121-
print("files before wait: " + '\n'.join(map(str, files)))
122-
time.sleep(2)
123-
files = glob.glob(tobeglobbed)
124-
print("files after wait: " + '\n'.join(map(str, files)))
125-
126-
assert len(files) > 0, "no image file found in folder:"+tobeglobbed
127-
128-
# latest first
129-
files = sorted(files, key=os.path.getctime, reverse=True)
130-
131102
mixedImages = []
103+
132104
try:
133105
# vectorize
134-
for i,img in enumerate(images[::-1]):
106+
for i,img in enumerate(proc.images[::-1]):
135107
if (not hasattr(img,"already_saved_as")) : continue
136-
fullfn = files[i]
108+
fullfn = img.already_saved_as
137109
fullfnPath = pathlib.Path(fullfn)
138110

139111
fullofpnm = fullfnPath.with_suffix('.pnm') #for vectorizing

0 commit comments

Comments
 (0)