From 7e375df5b11da3175b2e173e3ef40667b0d28f06 Mon Sep 17 00:00:00 2001 From: Debulois Quentin Date: Wed, 16 Sep 2020 14:31:02 +0200 Subject: Création d'une base correcte pour le projet en vue d'un vrai passage sur POO MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 8 +- Redim.spec | 35 +++++ Redim/Ressources/icon.ico | Bin 0 -> 23753 bytes Redim/__pycache__/main.cpython-38.pyc | Bin 0 -> 8337 bytes Redim/main.py | 284 ++++++++++++++++++++++++++++++++++ icon.ico | Bin 23753 -> 0 bytes redimensionner.py | 284 ---------------------------------- redimensionner.spec | 33 ---- requierments.txt | 9 ++ 9 files changed, 335 insertions(+), 318 deletions(-) create mode 100644 Redim.spec create mode 100644 Redim/Ressources/icon.ico create mode 100644 Redim/__pycache__/main.cpython-38.pyc create mode 100644 Redim/main.py delete mode 100644 icon.ico delete mode 100755 redimensionner.py delete mode 100644 redimensionner.spec create mode 100644 requierments.txt diff --git a/.gitignore b/.gitignore index fd3fb9e..878f4e7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,8 @@ -Cpp +# created by virtualenv automatically +Scripts +Lib +Build +Dist +Test TEST +pyvenv.cfg diff --git a/Redim.spec b/Redim.spec new file mode 100644 index 0000000..90e7672 --- /dev/null +++ b/Redim.spec @@ -0,0 +1,35 @@ +# -*- mode: python ; coding: utf-8 -*- + +block_cipher = None + + +a = Analysis(['Redim/main.py'], + pathex=[], + binaries=[], + datas=[], + hiddenimports=['Pillow'], + 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, + a.zipfiles, + a.datas, + [], + name='Redim', + debug=False, + bootloader_ignore_signals=False, + strip=False, + upx=True, + upx_exclude=[], + runtime_tmpdir=None, + console=True , icon='Redim/Ressources/icon.ico') diff --git a/Redim/Ressources/icon.ico b/Redim/Ressources/icon.ico new file mode 100644 index 0000000..5ffcc5c Binary files /dev/null and b/Redim/Ressources/icon.ico differ diff --git a/Redim/__pycache__/main.cpython-38.pyc b/Redim/__pycache__/main.cpython-38.pyc new file mode 100644 index 0000000..b759172 Binary files /dev/null and b/Redim/__pycache__/main.cpython-38.pyc differ diff --git a/Redim/main.py b/Redim/main.py new file mode 100644 index 0000000..4dc4a49 --- /dev/null +++ b/Redim/main.py @@ -0,0 +1,284 @@ +#!/usr/bin/python + +""" +Nécessite Pillow & PyQt5 +""" + +import json +from os import system, listdir, mkdir, environ, getenv +from os.path import join, isfile, isdir, getmtime +from sys import platform, exit +from time import time +from shutil import rmtree +from PIL.Image import ANTIALIAS +from PIL.Image import new as image_new +from PIL.Image import open as image_open +from PyQt5.QtWidgets import QFileDialog, QApplication, QWidget + + +class Redim(): + def __init__(self, formats_acceptes): + self.formats_acceptes = formats_acceptes + + def start(self, dossier, larg, haut, background_color, format_final): + if dossier == "": + print(" >>>ERREUR<<< : Aucun dossier selectionne.") + return + if isdir(dossier): + liste_fichier, dossier_sauvegarde = self.listage_fichiers_et_dossiers(dossier, larg) + self.main(liste_fichier, dossier_sauvegarde, larg, haut, background_color, format_final) + else: + print(" >>>ERREUR<<< : Le dossier n'existe plus.") + + def listage_fichiers_et_dossiers(self, dossier, larg): + liste_fichier = [] + dossier_sauvegarde = join(dossier, str(larg)) + if not isdir(dossier_sauvegarde): + mkdir(dossier_sauvegarde) + for nom in listdir(dossier): + if isfile(join(dossier, nom)): + if join(dossier, nom).rsplit(".", 1)[-1] in self.formats_acceptes: + liste_fichier.append([join(dossier, nom), nom]) + return liste_fichier, dossier_sauvegarde + + def suppression_de_alpha(self, img, background_color): + img = img.convert("RGBA") + if img.mode in ("RGBA", "LA"): + fond = image_new(img.mode[:-1], img.size, background_color) + fond.paste(img, img.split()[-1]) + img = fond + img.convert("RGB") + return img + + def redimensionnement(self, img, larg, haut): + if (img.size[0] >= larg) or (img.size[1] >= haut): + img.thumbnail((larg, haut), ANTIALIAS) + elif (img.size[0] / img.size[1]) <= (larg / haut): + nouvelle_larg = int(haut * img.size[0] / img.size[1]) + img = img.resize((nouvelle_larg, haut), ANTIALIAS) + else: + nouvelle_haut = int(larg * img.size[1] / img.size[0] ) + img = img.resize((larg, nouvelle_haut), ANTIALIAS) + return img + + def rennomage(self, origine_nom, larg, format_final): + charcters_indesirable = ("(", ")", "[", "]", "{", "}","'", "#", + "&","$","£", "¤", "€", "`", "^", "°", "¨", + "@", "!", ",", "~", "%", ";", "µ", "§") + charcters_underscore = (" ", "-") + nouveau_nom = origine_nom + for i in charcters_indesirable: + nouveau_nom = nouveau_nom.replace(i, "") + for i in charcters_underscore: + nouveau_nom = nouveau_nom.replace(i, "_") + return nouveau_nom.lower() + "_modif_" + str(larg) + format_final + + def main(self, liste_fichier, dossier_sauvegarde, larg, haut, background_color, format_final): + for nom in liste_fichier: + try: + print(" [+] Travail sur :", nom[1]) + img = image_open(nom[0]) + print(" >> Taille initiale :", img.size[0] ,"x" ,img.size[1], "px") + if nom[1].rsplit(".", 1)[-1] in ("png", "webp"): + img = self.suppression_de_alpha(img, background_color) + img = self.redimensionnement(img, larg, haut) + print(" >> Taille apres redimensionnement :", img.size[0] ,"x" ,img.size[1], "px") + nouveau_nom = self.rennomage(nom[1].rsplit(".", 1)[0], larg, format_final) + fond = image_new("RGB", (larg, haut), background_color) + fond.paste(img, ((larg - img.size[0]) // 2, (haut - img.size[1]) // 2)) + if isfile(join(dossier_sauvegarde, nouveau_nom)): + adverbes_multplicatifs = ("_bis", "_ter", "_quater", "_quinquies", "_sexies", "_septies") + nom_deja_present = nouveau_nom + iteration = 0 + while isfile(join(dossier_sauvegarde, nom_deja_present)): + nom_deja_present = nouveau_nom.rsplit(".", 1)[0] + adverbes_multplicatifs[iteration] + nom_deja_present += format_final + iteration += 1 + fond.save(join(dossier_sauvegarde, nom_deja_present)) + else: + fond.save(join(dossier_sauvegarde, nouveau_nom)) + except Exception as e: + print(" >>>ERREUR<<< : ", e) + + def nettoyage_pyinstaller(self): + for i in listdir(environ["TMP"]): + if i.startswith("_MEI") and isdir(i) and (int(getmtime(join(environ["TMP"], i))) < (time() - 86400)): + rmtree(join(environ["TMP"], i)) + + +def reset_screen(banner): + if platform != "linux": + system("cls") + else: + system("clear") + print(*banner) + +def sauvegarde_json(json_path, largeur1, hauteur1, largeur2, hauteur2, background_color, format_final): + dictionnaire = { + "dimensions" : [[largeur1, hauteur1], [largeur2,hauteur2]], + "background_color" : background_color, + "format_final" : format_final + } + if not isdir(json_path): + mkdir(json_path) + with open(join(json_path, "config_redim"), "w") as f: + json.dump(dictionnaire, f) + +def lecture_json(json_path): + with open(join(json_path, "config_redim"), "r") as f: + dictionnaire = json.load(f) + largeur1 = dictionnaire["dimensions"][0][0] + hauteur1 = dictionnaire["dimensions"][0][1] + largeur2 = dictionnaire["dimensions"][1][0] + hauteur2 = dictionnaire["dimensions"][1][1] + background_color = dictionnaire["background_color"] + format_final = dictionnaire["format_final"] + return largeur1, hauteur1, largeur2, hauteur2, background_color, format_final + +if __name__ == "__main__": + largeur1 = 500 + hauteur1 = 350 + largeur2 = 900 + hauteur2 = 900 + background_color = [255, 255, 255] + format_final = ".webp" + formats_acceptes = ("jpg", "jpeg", "png", "bmp", "gif", "webp") + json_path = join(getenv("USERPROFILE"), "AppData", "Local", "Redim") + app = QApplication([]) + widget = QWidget() + while True: + redim = Redim(formats_acceptes) + if not isfile(join(json_path, "config_redim")): + sauvegarde_json(json_path, largeur1, hauteur1, largeur2, hauteur2, background_color, format_final) + else: + largeur1, hauteur1, largeur2, hauteur2, background_color, format_final = lecture_json(json_path) + if platform != "linux": + redim.nettoyage_pyinstaller() + banner = ( + "\n ____ _ ____ ____ \n", + "| _ \\ _ __ ___ _ __ (_)_ _ _ __ ___ | _ \\ / ___|\n", + "| |_) | '__/ _ \\ '_ \\| | | | | '_ ` _ \\| |_) | | \n", + "| __/| | | __/ | | | | |_| | | | | | | __/| |___ \n", + "|_| |_| \\___|_| |_|_|\\__,_|_| |_| |_|_| \\____|\n", + "\n######################################################\n", + "\n[-] taille 1:", largeur1, "x", hauteur1, ", taille 2:", largeur2, "x", hauteur2, + "\n[-] rgb background:", background_color, + "\n[-] formats acceptes:", formats_acceptes, + "\n[-] format de sortie:", format_final, + "\n\n######################################################" + ) + menu = ( + "\n[-] Que faire?\n", + "\n (1) -> Conversion (", largeur1, "x", hauteur1, "px et", largeur2, "x", hauteur2, "px)", + "\n (5) -> Modification des tailles", + "\n (6) -> Modification du RGB", + "\n (7) -> Modification du format de sortie", + "\n (8) -> Reset des parametres", + "\n (9) -> Quitter\n" + ) + reset_screen(banner) + print(*menu) + choix = input("[>] Choix (numero) : ") + while True: + reset_screen(banner) + if choix.strip() == "1": + dossier = QFileDialog.getExistingDirectory( + widget, + "Dossier a travailler." + ) + print("\n[-] travail pour", largeur1, "x", hauteur1, "px :") + redim.start(dossier, largeur1, hauteur1, tuple(background_color), format_final) + print("\n[-] travail pour", largeur2, "x", hauteur2, "px :") + redim.start(dossier, largeur2, hauteur2, tuple(background_color), format_final) + input("\n[-] fin, appuyer sur \'entrer\' pour recommencer .") + break + elif choix.strip() == "5": + reset_screen(banner) + dimensions = [0, 0, 0, 0] + for pos, i in enumerate(dimensions): + if pos == 0: + print("\n[-] Taille 1:") + elif pos == 2: + print("\n[-] Taille 2:") + while True: + texte = [" [>] Largeur : ", " [>] Hauteur : "] + dimensions[pos] = input(texte[pos % 2]) + try: + dimensions[pos] = int(dimensions[pos].strip()) + break + except: + print(" >>>ERREUR<<< Valeur incorrecte.") + largeur1 = dimensions[0] + hauteur1 = dimensions[1] + largeur2 = dimensions[2] + hauteur2 = dimensions[3] + sauvegarde_json(json_path, largeur1, hauteur1, largeur2, hauteur2, background_color, format_final) + print("\n[-] Modification effectue.") + input("\n[-] fin, appuyer sur \'entrer\' pour recommencer .") + break + elif choix.strip() == "6": + reset_screen(banner) + nouveau_background_color = [0, 0, 0] + print("\n[-] Modification de la couleur du background (Valeur RGB 0-255):\n") + for pos, i in enumerate(background_color): + while True: + texte = [" [>] Valeur Rouge: ", " [>] Valeur Vert: ", " [>] Valeur Bleu: "] + nouveau_background_color[pos] = input(texte[pos]) + try: + nouveau_background_color[pos] = int(nouveau_background_color[pos].strip()) + if nouveau_background_color[pos] >= 0 and nouveau_background_color[pos] < 256: + break + else: + print(" >>>ERREUR<<< Valeur incorrecte.") + except: + print(" >>>ERREUR<<< Valeur incorrecte.") + background_color = nouveau_background_color + sauvegarde_json(json_path, largeur1, hauteur1, largeur2, hauteur2, background_color, format_final) + print("\n[-] Modification effectue.") + input("\n[-] fin, appuyer sur \'entrer\' pour recommencer .") + break + elif choix.strip() == "7": + print("\n[-] Modification du format de sortie:\n") + nombre = 1 + for i in formats_acceptes: + nombre_choix = "(" + str(nombre) + ") ->" + print(" ", nombre_choix, i) + nombre += 1 + nouveau_format = input("\n[>] Choix (numero) : ") + try: + nouveau_format = int(nouveau_format.strip()) + if nouveau_format > 0: + format_final = "." + formats_acceptes[nouveau_format - 1] + sauvegarde_json(json_path, largeur1, hauteur1, largeur2, hauteur2, background_color, format_final) + print("\n[-] Modification effectue.") + else: + print(">>>ERREUR<<< Choix invalide.") + input("\n[-] fin, appuyer sur \'entrer\' pour recommencer .") + break + except: + print(">>>ERREUR<<< Choix invalide.") + input("\n[-] fin, appuyer sur \'entrer\' pour recommencer .") + break + elif choix.strip() == "8": + reset_screen(banner) + print("\n[-] Reset des parametres.") + largeur1 = 500 + hauteur1 = 350 + largeur2 = 900 + hauteur2 = 900 + background_color = [255, 255, 255] + format_final = ".webp" + sauvegarde_json(json_path, largeur1, hauteur1, largeur2, hauteur2, background_color, format_final) + print("\n[-] Modification effectue.") + input("\n[-] fin, appuyer sur \'entrer\' pour recommencer .") + break + elif choix.strip() == "9": + if platform != "linux": + system("cls") + else: + system("clear") + exit(0) + else: + print("\n[-] Reponse invalide .") + input("\n[-] fin, appuyer sur \'entrer\' pour recommencer .") + break diff --git a/icon.ico b/icon.ico deleted file mode 100644 index 5ffcc5c..0000000 Binary files a/icon.ico and /dev/null differ diff --git a/redimensionner.py b/redimensionner.py deleted file mode 100755 index 505e5b7..0000000 --- a/redimensionner.py +++ /dev/null @@ -1,284 +0,0 @@ -#!/usr/bin/python - -""" -Nécessite Pillow & PyQt5 -""" - -import json -from os import system, listdir, mkdir, environ, getenv -from os.path import join, isfile, isdir, getmtime -from sys import platform, exit -from time import time -from shutil import rmtree -from PIL.Image import ANTIALIAS -from PIL.Image import new as image_new -from PIL.Image import open as image_open -from PyQt5.QtWidgets import QFileDialog, QApplication, QWidget - - -class Redim(): - def __init__(self, formats_acceptes): - self.formats_acceptes = formats_acceptes - - def start(self, dossier, larg, haut, background_color, format_final): - if dossier == "": - print(" >>>ERREUR<<< : Aucun dossier selectionne.") - return - if isdir(dossier): - liste_fichier, dossier_sauvegarde = self.listage_fichiers_et_dossiers(dossier, larg) - self.main(liste_fichier, dossier_sauvegarde, larg, haut, background_color, format_final) - else: - print(" >>>ERREUR<<< : Le dossier n'existe plus.") - - def listage_fichiers_et_dossiers(self, dossier, larg): - liste_fichier = [] - dossier_sauvegarde = join(dossier, str(larg)) - if not isdir(dossier_sauvegarde): - mkdir(dossier_sauvegarde) - for nom in listdir(dossier): - if isfile(join(dossier, nom)): - if join(dossier, nom).rsplit(".", 1)[-1] in self.formats_acceptes: - liste_fichier.append([join(dossier, nom), nom]) - return liste_fichier, dossier_sauvegarde - - def suppression_de_alpha(self, img, background_color): - img = img.convert("RGBA") - if img.mode in ("RGBA", "LA"): - fond = image_new(img.mode[:-1], img.size, background_color) - fond.paste(img, img.split()[-1]) - img = fond - img.convert("RGB") - return img - - def redimensionnement(self, img, larg, haut): - if (img.size[0] >= larg) or (img.size[1] >= haut): - img.thumbnail((larg, haut), ANTIALIAS) - elif (img.size[0] / img.size[1]) <= (larg / haut): - nouvelle_larg = int(haut * img.size[0] / img.size[1]) - img = img.resize((nouvelle_larg, haut), ANTIALIAS) - else: - nouvelle_haut = int(larg * img.size[1] / img.size[0] ) - img = img.resize((larg, nouvelle_haut), ANTIALIAS) - return img - - def rennomage(self, origine_nom, larg, format_final): - charcters_indesirable = ("(", ")", "[", "]", "{", "}","'", "#", - "&","$","£", "¤", "€", "`", "^", "°", "¨", - "@", "!", ",", "~", "%", ";", "µ", "§") - charcters_underscore = (" ", "-") - nouveau_nom = origine_nom - for i in charcters_indesirable: - nouveau_nom = nouveau_nom.replace(i, "") - for i in charcters_underscore: - nouveau_nom = nouveau_nom.replace(i, "_") - return nouveau_nom + "_modif_" + str(larg) + format_final - - def main(self, liste_fichier, dossier_sauvegarde, larg, haut, background_color, format_final): - for nom in liste_fichier: - try: - print(" [+] Travail sur :", nom[1]) - img = image_open(nom[0]) - print(" >> Taille initiale :", img.size[0] ,"x" ,img.size[1], "px") - if nom[1].rsplit(".", 1)[-1] in ("png", "webp"): - img = self.suppression_de_alpha(img, background_color) - img = self.redimensionnement(img, larg, haut) - print(" >> Taille apres redimensionnement :", img.size[0] ,"x" ,img.size[1], "px") - nouveau_nom = self.rennomage(nom[1].rsplit(".", 1)[0], larg, format_final) - fond = image_new("RGB", (larg, haut), background_color) - fond.paste(img, ((larg - img.size[0]) // 2, (haut - img.size[1]) // 2)) - if isfile(join(dossier_sauvegarde, nouveau_nom)): - adverbes_multplicatifs = ("_bis", "_ter", "_quater", "_quinquies", "_sexies", "_septies") - nom_deja_present = nouveau_nom - iteration = 0 - while isfile(join(dossier_sauvegarde, nom_deja_present)): - nom_deja_present = nouveau_nom.rsplit(".", 1)[0] + adverbes_multplicatifs[iteration] - nom_deja_present += format_final - iteration += 1 - fond.save(join(dossier_sauvegarde, nom_deja_present)) - else: - fond.save(join(dossier_sauvegarde, nouveau_nom)) - except Exception as e: - print(" >>>ERREUR<<< : ", e) - - def nettoyage_pyinstaller(self): - for i in listdir(environ["TMP"]): - if i.startswith("_MEI") and isdir(i) and (int(getmtime(join(environ["TMP"], i))) < (time() - 86400)): - rmtree(join(environ["TMP"], i)) - - -def reset_screen(banner): - if platform != "linux": - system("cls") - else: - system("clear") - print(*banner) - -def sauvegarde_json(json_path, largeur1, hauteur1, largeur2, hauteur2, background_color, format_final): - dictionnaire = { - "dimensions" : [[largeur1, hauteur1], [largeur2,hauteur2]], - "background_color" : background_color, - "format_final" : format_final - } - if not isdir(json_path): - mkdir(json_path) - with open(join(json_path, "config_redim"), "w") as f: - json.dump(dictionnaire, f) - -def lecture_json(json_path): - with open(join(json_path, "config_redim"), "r") as f: - dictionnaire = json.load(f) - largeur1 = dictionnaire["dimensions"][0][0] - hauteur1 = dictionnaire["dimensions"][0][1] - largeur2 = dictionnaire["dimensions"][1][0] - hauteur2 = dictionnaire["dimensions"][1][1] - background_color = dictionnaire["background_color"] - format_final = dictionnaire["format_final"] - return largeur1, hauteur1, largeur2, hauteur2, background_color, format_final - -if __name__ == "__main__": - largeur1 = 500 - hauteur1 = 350 - largeur2 = 900 - hauteur2 = 900 - background_color = [255, 255, 255] - format_final = ".webp" - formats_acceptes = ("jpg", "jpeg", "png", "bmp", "gif", "webp") - json_path = join(getenv("USERPROFILE"), "AppData", "Local", "Redim") - app = QApplication([]) - widget = QWidget() - while True: - redim = Redim(formats_acceptes) - if not isfile(join(json_path, "config_redim")): - sauvegarde_json(json_path, largeur1, hauteur1, largeur2, hauteur2, background_color, format_final) - else: - largeur1, hauteur1, largeur2, hauteur2, background_color, format_final = lecture_json(json_path) - if platform != "linux": - redim.nettoyage_pyinstaller() - banner = ( - "\n ____ _ ____ ____ \n", - "| _ \\ _ __ ___ _ __ (_)_ _ _ __ ___ | _ \\ / ___|\n", - "| |_) | '__/ _ \\ '_ \\| | | | | '_ ` _ \\| |_) | | \n", - "| __/| | | __/ | | | | |_| | | | | | | __/| |___ \n", - "|_| |_| \\___|_| |_|_|\\__,_|_| |_| |_|_| \\____|\n", - "\n######################################################\n", - "\n[-] taille 1:", largeur1, "x", hauteur1, ", taille 2:", largeur2, "x", hauteur2, - "\n[-] rgb background:", background_color, - "\n[-] formats acceptes:", formats_acceptes, - "\n[-] format de sortie:", format_final, - "\n\n######################################################" - ) - menu = ( - "\n[-] Que faire?\n", - "\n (1) -> Conversion (", largeur1, "x", hauteur1, "px et", largeur2, "x", hauteur2, "px)", - "\n (5) -> Modification des tailles", - "\n (6) -> Modification du RGB", - "\n (7) -> Modification du format de sortie", - "\n (8) -> Reset des parametres", - "\n (9) -> Quitter\n" - ) - reset_screen(banner) - print(*menu) - choix = input("[>] Choix (numero) : ") - while True: - reset_screen(banner) - if choix.strip() == "1": - dossier = QFileDialog.getExistingDirectory( - widget, - "Dossier a travailler." - ) - print("\n[-] travail pour", largeur1, "x", hauteur1, "px :") - redim.start(dossier, largeur1, hauteur1, tuple(background_color), format_final) - print("\n[-] travail pour", largeur2, "x", hauteur2, "px :") - redim.start(dossier, largeur2, hauteur2, tuple(background_color), format_final) - input("\n[-] fin, appuyer sur \'entrer\' pour recommencer .") - break - elif choix.strip() == "5": - reset_screen(banner) - dimensions = [0, 0, 0, 0] - for pos, i in enumerate(dimensions): - if pos == 0: - print("\n[-] Taille 1:") - elif pos == 2: - print("\n[-] Taille 2:") - while True: - texte = [" [>] Largeur : ", " [>] Hauteur : "] - dimensions[pos] = input(texte[pos % 2]) - try: - dimensions[pos] = int(dimensions[pos].strip()) - break - except: - print(" >>>ERREUR<<< Valeur incorrecte.") - largeur1 = dimensions[0] - hauteur1 = dimensions[1] - largeur2 = dimensions[2] - hauteur2 = dimensions[3] - sauvegarde_json(json_path, largeur1, hauteur1, largeur2, hauteur2, background_color, format_final) - print("\n[-] Modification effectue.") - input("\n[-] fin, appuyer sur \'entrer\' pour recommencer .") - break - elif choix.strip() == "6": - reset_screen(banner) - nouveau_background_color = [0, 0, 0] - print("\n[-] Modification de la couleur du background (Valeur RGB 0-255):\n") - for pos, i in enumerate(background_color): - while True: - texte = [" [>] Valeur Rouge: ", " [>] Valeur Vert: ", " [>] Valeur Bleu: "] - nouveau_background_color[pos] = input(texte[pos]) - try: - nouveau_background_color[pos] = int(nouveau_background_color[pos].strip()) - if nouveau_background_color[pos] >= 0 and nouveau_background_color[pos] < 256: - break - else: - print(" >>>ERREUR<<< Valeur incorrecte.") - except: - print(" >>>ERREUR<<< Valeur incorrecte.") - background_color = nouveau_background_color - sauvegarde_json(json_path, largeur1, hauteur1, largeur2, hauteur2, background_color, format_final) - print("\n[-] Modification effectue.") - input("\n[-] fin, appuyer sur \'entrer\' pour recommencer .") - break - elif choix.strip() == "7": - print("\n[-] Modification du format de sortie:\n") - nombre = 1 - for i in formats_acceptes: - nombre_choix = "(" + str(nombre) + ") ->" - print(" ", nombre_choix, i) - nombre += 1 - nouveau_format = input("\n[>] Choix (numero) : ") - try: - nouveau_format = int(nouveau_format.strip()) - if nouveau_format > 0: - format_final = "." + formats_acceptes[nouveau_format - 1] - sauvegarde_json(json_path, largeur1, hauteur1, largeur2, hauteur2, background_color, format_final) - print("\n[-] Modification effectue.") - else: - print(">>>ERREUR<<< Choix invalide.") - input("\n[-] fin, appuyer sur \'entrer\' pour recommencer .") - break - except: - print(">>>ERREUR<<< Choix invalide.") - input("\n[-] fin, appuyer sur \'entrer\' pour recommencer .") - break - elif choix.strip() == "8": - reset_screen(banner) - print("\n[-] Reset des parametres.") - largeur1 = 500 - hauteur1 = 350 - largeur2 = 900 - hauteur2 = 900 - background_color = [255, 255, 255] - format_final = ".webp" - sauvegarde_json(json_path, largeur1, hauteur1, largeur2, hauteur2, background_color, format_final) - print("\n[-] Modification effectue.") - input("\n[-] fin, appuyer sur \'entrer\' pour recommencer .") - break - elif choix.strip() == "9": - if platform != "linux": - system("cls") - else: - system("clear") - exit(0) - else: - print("\n[-] Reponse invalide .") - input("\n[-] fin, appuyer sur \'entrer\' pour recommencer .") - break diff --git a/redimensionner.spec b/redimensionner.spec deleted file mode 100644 index 4162e16..0000000 --- a/redimensionner.spec +++ /dev/null @@ -1,33 +0,0 @@ -# -*- mode: python ; coding: utf-8 -*- - -block_cipher = None - - -a = Analysis(['redimensionner.py'], - pathex=['D:\\Mes documents W10\\Desktop'], - binaries=[], - datas=[], - hiddenimports=['Pillow'], - 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, - a.zipfiles, - a.datas, - [], - name='redimensionner', - debug=False, - bootloader_ignore_signals=False, - strip=False, - upx=True, - upx_exclude=[], - runtime_tmpdir=None, - console=True , icon='icon.ico') diff --git a/requierments.txt b/requierments.txt new file mode 100644 index 0000000..575c123 --- /dev/null +++ b/requierments.txt @@ -0,0 +1,9 @@ +altgraph==0.17 +future==0.18.2 +pefile==2019.4.18 +Pillow==7.2.0 +pyinstaller==4.0 +pyinstaller-hooks-contrib==2020.8 +PyQt5==5.15.1 +PyQt5-sip==12.8.1 +pywin32-ctypes==0.2.0 -- cgit v1.2.3