From 62b66166f4f7b96419e6d4868f77c42de85c66d8 Mon Sep 17 00:00:00 2001 From: Herr L Date: Wed, 8 Feb 2017 03:10:30 +0100 Subject: [PATCH] initial commit --- .gitignore | 46 ++ .idea/.name | 1 + .idea/dbnavigator.xml | 461 ++++++++++++++++++ .idea/markdown-navigator.xml | 68 +++ .../markdown-navigator/profiles_settings.xml | 3 + .idea/misc.xml | 6 + .idea/modules.xml | 8 + .idea/vcs.xml | 6 + ProjectLifer.iml | 9 + ProjectLifer.py | 132 +++++ build.bat | 3 + 11 files changed, 743 insertions(+) create mode 100644 .gitignore create mode 100644 .idea/.name create mode 100644 .idea/dbnavigator.xml create mode 100644 .idea/markdown-navigator.xml create mode 100644 .idea/markdown-navigator/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 ProjectLifer.iml create mode 100644 ProjectLifer.py create mode 100644 build.bat diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0d2d851 --- /dev/null +++ b/.gitignore @@ -0,0 +1,46 @@ +build/ +dist/ +*.spec + +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff: +.idea/**/workspace.xml +.idea/**/tasks.xml + +# Sensitive or high-churn files: +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.xml +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml + +# Gradle: +.idea/**/gradle.xml +.idea/**/libraries + +# Mongo Explorer plugin: +.idea/**/mongoSettings.xml + +## File-based project format: +*.iws + +## Plugin-specific files: + +# IntelliJ +/out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties \ No newline at end of file diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..699ab91 --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +ProjectLifer \ No newline at end of file diff --git a/.idea/dbnavigator.xml b/.idea/dbnavigator.xml new file mode 100644 index 0000000..f0fae64 --- /dev/null +++ b/.idea/dbnavigator.xml @@ -0,0 +1,461 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/markdown-navigator.xml b/.idea/markdown-navigator.xml new file mode 100644 index 0000000..0f9e44c --- /dev/null +++ b/.idea/markdown-navigator.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/markdown-navigator/profiles_settings.xml b/.idea/markdown-navigator/profiles_settings.xml new file mode 100644 index 0000000..674a591 --- /dev/null +++ b/.idea/markdown-navigator/profiles_settings.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..1904789 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..6199976 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ProjectLifer.iml b/ProjectLifer.iml new file mode 100644 index 0000000..ad3c0a3 --- /dev/null +++ b/ProjectLifer.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/ProjectLifer.py b/ProjectLifer.py new file mode 100644 index 0000000..45423e2 --- /dev/null +++ b/ProjectLifer.py @@ -0,0 +1,132 @@ +from tkinter import * +from tkinter import filedialog, ttk +from tkinter.ttk import * +import os +from PIL import Image + + +class ProjectLiferFrame(Frame): + files = list() + + def __init__(self, root): + + ttk.Frame.__init__(self, root, padding=(5, 5, 5, 5)) + + # define buttons + self.butcombine = Button(self, text='Kombiniere Bilder', command=self.combine_pictures) + self.butdirchooser = Button(self, text='Verzeichnis wählen', command=self.askdirectory) + self.butselall = Button(self, text='Alle wählen', command=self.select_all) + self.butselnone = Button(self, text='Keine wählen', command=self.select_none) + + # define ProgressBar + self.pbar = Progressbar(self) + + self.listbox = Listbox(self, selectmode=MULTIPLE) + self.scrollbar = Scrollbar(self.listbox, orient=VERTICAL) + + self.listbox.config(yscrollcommand=self.scrollbar.set) + self.scrollbar.config(command=self.listbox.yview) + + self.butcombine.grid(row=0, rowspan=2, columnspan=2, sticky=W + E + N + S, padx=5, pady=5) + self.butdirchooser.grid(row=2, columnspan=2, padx=5, pady=5) + self.butselall.grid(row=3, column=0) + self.butselnone.grid(row=3, column=1) + self.pbar.grid(row=4, columnspan=3, sticky=W + E + N + S, pady=5, padx=5) + self.listbox.grid(column=2, row=0, rowspan=4, columnspan=2, sticky=W + E + N + S, pady=5, padx=5) + self.listbox.columnconfigure(0, weight=1) + self.listbox.rowconfigure(0, weight=1) + self.scrollbar.grid(column=1, sticky=N + S) + + # defining options for opening a directory + self.dir_opt = options = {} + options['initialdir'] = 'C:\\' + options['mustexist'] = False + options['parent'] = root + options['title'] = 'This is a title' + self.columnconfigure(0, weight=1) + self.columnconfigure(1, weight=1) + self.columnconfigure(2, weight=10) + self.rowconfigure(0, weight=5) + self.rowconfigure(1, weight=1) + self.rowconfigure(2, weight=1) + self.rowconfigure(3, weight=1) + + def combine_pictures(self): + + """Combines two pictures into one.""" + items = self.listbox.curselection() + items = [self.files[int(item)] for item in items] + + self.pbar["value"] = 0 + self.pbar["maximum"] = int(round(len(items) / 2)) + root.update_idletasks() + items = iter(items) + + for i1, path in items: + img1 = self.fixpicture(Image.open(path)) + i2, path = next(items, (i1, path)) + img2 = self.fixpicture(Image.open(path)) + # resize smaller picture + x1, y1 = img1.size + x2, y2 = img2.size + if x1 < x2: + img1 = img1.resize((x2, y2)) + x, y = x2, y2 + else: + img2 = img2.resize((x1, y1)) + x, y = x1, y1 + new_im = Image.new('RGB', (x + x, y)) + new_im.paste(img1, (0, 0)) + new_im.paste(img2, (x, 0)) + savepath = os.path.dirname(path) + imgname1 = os.path.splitext(os.path.basename(i1))[0] + imgname2 = os.path.splitext(os.path.basename(i2))[0] + new_im.save(self.folder + os.path.sep + '{}_and_{}.jpg'.format(imgname1, imgname2)) + + self.pbar["value"] += 1 + root.update_idletasks() + + return + + def fixpicture(self, picture): + x, y = picture.size + if x > y: + picture = picture.rotate(90, expand=True) + x, y = y, x + # fix ratio + if x / 3 * 4 > y: + x = int(y / 4 * 3) + elif x / 3 * 4 < y: + y = int(x / 3 * 4) + return picture.resize((x, y)) + + def askdirectory(self): + + """Returns a selected directoryname.""" + self.listbox.delete(0, END) + self.folder = filedialog.askdirectory(**self.dir_opt) + for file in os.listdir(self.folder): + pathfile = os.path.join(self.folder, file) + if os.path.isfile(pathfile): + self.files.append((file, pathfile)) + + for key, value in self.files: + self.listbox.insert(END, key) + + return + + def select_all(self): + self.listbox.selection_set(0, END) + + def select_none(self): + self.listbox.selection_clear(0, END) + + +if __name__ == '__main__': + root = Tk() + root.columnconfigure(0, weight=1) + root.rowconfigure(0, weight=1) + root.minsize(700, 500) + root.title("ProjectLifer 1.0.0") + ProjectLiferFrame(root).grid(row=0, column=0, sticky=(N, S, E, W)) + root.mainloop() diff --git a/build.bat b/build.bat new file mode 100644 index 0000000..d827c79 --- /dev/null +++ b/build.bat @@ -0,0 +1,3 @@ +pyinstaller --noconfirm --log-level=WARN ^ + --onefile --nowindow ^ + ProjectLifer.py \ No newline at end of file