Skip to content

Commit

Permalink
Fixing program so it works for png files and some other small updates
Browse files Browse the repository at this point in the history
  • Loading branch information
HDCharles committed Aug 15, 2021
1 parent 111fda2 commit 703699e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions TTStoPnp.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/python

# make exe with: pyinstaller --onefile --icon=TTStoPnp.ico TTStoPnp.py
# make exe with: pyinstaller --onefile --noupx --icon=TTStoPnp.png TTStoPnp.py

from tkinter import filedialog
import tkinter as tk
Expand All @@ -26,17 +26,20 @@ def useCurDir():


def selectDir():
top.dir = tk.filedialog.askdirectory(initialdir="/", title="Select Directory",)
top.dir = tk.filedialog.askdirectory(
initialdir="/",
title="Select Directory (files not shown)",
)
# setupText()
setupSelector()


def setupText():
text.delete(1.0, tk.END)
text.insert(tk.INSERT, "dir: " + top.dir)
text.pack()
# def setupText():
# text.delete(1.0, tk.END)
# text.insert(tk.INSERT, "dir: " + top.dir)
# text.pack()

# setupSelector()
# setupSelector()


def getImages():
Expand Down Expand Up @@ -77,8 +80,12 @@ def nextCardLocation(cardCol, cardRow):
cardCol = 0
cardRow = 0
count = 0

imgData = numpy.asarray(image)
page = numpy.ones((cardHeight * 3 + 2, cardWidth * 3 + 2, 3)) * 255
imageChannels = imgData.shape[2]

page = numpy.ones((cardHeight * 3 + 2, cardWidth * 3 + 2, imageChannels)) * 255

for i in range(rows):
for j in range(cols):

Expand All @@ -87,7 +94,7 @@ def nextCardLocation(cardCol, cardRow):
j * cardWidth : (j + 1) * cardWidth,
:,
]
if card.sum() > 0:
if card[:, :, :3].sum() > 0:
page[
cardRow * (cardHeight + 1) : cardRow * (cardHeight + 1)
+ cardHeight,
Expand All @@ -103,7 +110,10 @@ def nextCardLocation(cardCol, cardRow):
os.path.join(directory, "sep" + str(count) + "-" + filename)
)
count += 1
page = numpy.ones((cardHeight * 3 + 2, cardWidth * 3 + 2, 3)) * 255
page = (
numpy.ones((cardHeight * 3 + 2, cardWidth * 3 + 2, imageChannels))
* 255
)
return count


Expand Down Expand Up @@ -155,7 +165,7 @@ def setupSelector():
text="Help",
command=lambda: tk.messagebox.showinfo(
"Instructions",
"1) Select your desired directory\n2) Input each image's card dimensions\n3) Leave 0,0 for images you wish to ignore \nNote: images with names that start with 'sep' are ignored",
"1) Select your desired directory\n2) Input each image's card dimensions (usually 7, 10 for TTS)\n3) Leave 0,0 for images you wish to ignore\n4) Separate Images\nNote: images with names that start with 'sep' are ignored",
),
)
sep.pack(in_=comButtons, side=tk.LEFT)
Expand Down
Binary file modified __pycache__/TTStoPnp.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/TTStoPnp.cpython-38.pyc
Binary file not shown.

0 comments on commit 703699e

Please sign in to comment.