Skip to content

Commit

Permalink
test two workflows.
Browse files Browse the repository at this point in the history
  • Loading branch information
bperseghetti committed Sep 10, 2022
1 parent b684e13 commit bdf944e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 22 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 26 additions & 22 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,28 +149,32 @@ def listfiles(path):
def check_generate(file_path):
name_file = './docs/'+file_path
image_name = name_file.replace(".stl",".png")
if not os.path.exists(image_name) and flag_gen_image:
print('INFO\t - {:s}Attempting to generate:{:s} {:s} -> {:s}'.format(cl.GRN,cl.END,name_file,image_name))
try:
mesh = Mesh.from_file(name_file)
fig=vpl.figure()
vpl.mesh_plot(mesh,fig=fig,color=(60,116,179))
vpl.save_fig(path=image_name, trim_pad_width=5, pixels=640, off_screen=True, fig=fig)
except:
return False
print('ERROR\t - {:s}Failed to generate:{:s} {:s} -> {:s}'.format(cl.FAIL,cl.END,name_file,image_name))
else:
if not os.path.exists(image_name):
if flag_gen_image:
print('INFO\t - {:s}Attempting to generate:{:s} {:s} -> {:s}'.format(cl.GRN,cl.END,name_file,image_name))
try:
img = Image.open(image_name)
img = img.convert("RGBA")
pixdata = img.load()
width, height = img.size
for y in range(height):
for x in range(width):
if pixdata[x, y] == (216, 220, 214, 255):
pixdata[x, y] = (255, 255, 255, 0)

img.save(image_name, "PNG")
mesh = Mesh.from_file(name_file)
fig=vpl.figure()
vpl.mesh_plot(mesh,fig=fig,color=(60,116,179))
vpl.save_fig(path=image_name, trim_pad_width=5, pixels=640, off_screen=True, fig=fig)
except:
print('WARN\t - {:s}Failed to remove background in:{:s} {:s}'.format(cl.WARN,cl.END,image_name))
return False
print('ERROR\t - {:s}Failed to generate:{:s} {:s} -> {:s}'.format(cl.FAIL,cl.END,name_file,image_name))
else:
try:
img = Image.open(image_name)
img = img.convert("RGBA")
pixdata = img.load()
width, height = img.size
for y in range(height):
for x in range(width):
if pixdata[x, y] == (216, 220, 214, 255):
pixdata[x, y] = (255, 255, 255, 0)

img.save(image_name, "PNG")
except:
print('WARN\t - {:s}Failed to remove background in:{:s} {:s}'.format(cl.WARN,cl.END,image_name))
return True
else:
return False
return True

0 comments on commit bdf944e

Please sign in to comment.