Skip to content

Commit

Permalink
Merge pull request from pepijnmm
Browse files Browse the repository at this point in the history
- Adds Webp support
- Adds instructions to compile builds
  • Loading branch information
MechTechnology authored Jun 14, 2021
2 parents b85166e + 8d68f33 commit d5bcfeb
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
__pycache__/
dist/
build/
settings.pickle
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,11 @@ It's not fancy, and does not use AI, but it's fast, simple and more importantly
- Before slicing thou, it checks the row of pixels it will slice at if there is bubbles or whatever, it compares neighbouring pixels for any drastic jump in value, (tolarence for value jumps is the sentivity)
- if there is too big of a jump in value between the pixels, that means there is something that shouldn't be cut, so it move up a pixel row and repeat.
- For senstivity 100 will mean if the pixel row that it will slice at will have to be the same color, 0 being it does not care so it will cut there

### How to built --Windows
1. install PyInstaller if you haven't yet with the following command: pip install pyinstaller
3. then to create a build do: pyinstaller SmartStitchGUI.spec

### How single file --Windows
1. install PyInstaller if you haven't yet with the following command: pip install pyinstaller
3. then to create a build do: pyinstaller singleFile.spec
14 changes: 11 additions & 3 deletions SmartStitchGUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,18 @@ def __init__(self, *args, **kwargs):
self.SetupActionFrame().grid(row=3, column=0, padx=(15), pady=(0,15), sticky="new")
self.LoadPrevSettings()

def geticon(self, relative_path):
if not hasattr(sys, "frozen"):
relative_path = os.path.join(os.path.dirname(__file__), relative_path)
else:
relative_path = os.path.join(sys.prefix, relative_path)
return relative_path

# return os.path.join(base_path, relative_path)
def SetupWindow(self):
# Sets up Title and Logo
self.title('SmartStitch by MechTechnology [1.4]')
self.iconphoto(False, PhotoImage(file = "SmartStitchLogo.png"))
self.iconbitmap(default=self.geticon("SmartStitchLogo.ico"))

# Sets Window Size, centers it on Launch and Prevents Resize.
window_width = self.winfo_width()
Expand Down Expand Up @@ -108,7 +116,7 @@ def SetupSettingsFrame(self):
senstivity_field.bind("<Any-KeyRelease>", self.SaveCurrentSettings)
senstivity_field['validatecommand'] = (senstivity_field.register(self.AllowPercentOnly),'%P','%d','%s')
type_label = ttk.Label(settings_frame, text = 'Output Images Type:')
type_dropdown = ttk.Combobox(settings_frame, textvariable=self.output_type, values=('.jpg', '.png', '.bmp', '.tiff', '.tga'))
type_dropdown = ttk.Combobox(settings_frame, textvariable=self.output_type, values=('.jpg', '.png', '.webp', '.bmp', '.tiff', '.tga'))
type_dropdown.bind("<<ComboboxSelected>>", self.SaveCurrentSettings)
split_label.grid(row=0, column=0, sticky="new")
split_field.grid(row=1, column=0, pady=(2,0), sticky="new")
Expand Down Expand Up @@ -162,7 +170,7 @@ def LoadImages(self):
return images
folder = os.path.abspath(str(self.input_folder.get()))
for imgFile in os.listdir(folder):
if imgFile.endswith(('.png', '.jpg', '.jpeg', '.bmp', '.tiff', '.tga')):
if imgFile.endswith(('.png', '.webp', '.jpg', '.jpeg', '.bmp', '.tiff', '.tga')):
imgPath = os.path.join(folder, imgFile)
image = pil.open(imgPath)
images.append(image)
Expand Down
4 changes: 2 additions & 2 deletions SmartStitchGUI.spec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ block_cipher = None


a = Analysis(['SmartStitchGUI.py'],
pathex=['C:\\Users\\mosta\\Source Codes\\Public Projects\\SmartStitcher'],
pathex=['.'],
binaries=[],
datas=[],
hiddenimports=[],
Expand All @@ -29,7 +29,7 @@ exe = EXE(pyz,
upx=True,
console=False , icon='SmartStitchLogo.ico')
coll = COLLECT(exe,
a.binaries,
a.binaries + [('SmartStitchLogo.ico', 'SmartStitchLogo.ico', 'DATA')],
a.zipfiles,
a.datas,
strip=False,
Expand Down
34 changes: 34 additions & 0 deletions singleFile.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# -*- mode: python ; coding: utf-8 -*-


block_cipher = None


a = Analysis(['SmartStitchGUI.py'],
pathex=['.'],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
a.binaries + [('SmartStitchLogo.ico', 'SmartStitchLogo.ico', 'DATA')],
a.zipfiles,
a.datas,
[],
name='SmartStitchGUI',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=False , icon='SmartStitchLogo.ico')

0 comments on commit d5bcfeb

Please sign in to comment.