From 8374c9370fc74c3ec3350523b14ab6d4b5270181 Mon Sep 17 00:00:00 2001 From: ABelliqueux Date: Tue, 20 Feb 2024 09:55:14 +0100 Subject: [PATCH] Fix remove/rename frames --- config.toml | 2 +- main_c.py | 34 +++++++++++++++++----------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/config.toml b/config.toml index 9c4f771..b0214e9 100644 --- a/config.toml +++ b/config.toml @@ -10,7 +10,7 @@ fullscreen_bool = true screen_w = 1920 screen_h = 1080 framerate = 16 -vflip = true +vflip = false hflip = false export_options = 'scale=1920:-1,crop=1920:1080:0:102' [CAMERA] diff --git a/main_c.py b/main_c.py index 661d3b6..ec728b7 100644 --- a/main_c.py +++ b/main_c.py @@ -46,20 +46,20 @@ from send2trash import send2trash # X wait event mode # X remove frames # X keep images in memory (odict > list ?) -# / resize images upon shooting/crop output video ? +# X resize images upon shooting/crop output video ? # X project workflow # X use a different folder for each project (A, B, C, etc...) # X startup : check for existing folder with name A, B, C, etc. # X startup : offer to continue previous project or new project # X if continue, find last frame in folder X else, find next letter and create folder -# o notify export ending # X colored onion skin frame (pillow filters) # X startup frame -# o webcam support (pygame, win and linux only) # X Import config values from config file # X Translation +# X Allow opening and exporting without a camera connected # o Better settings names -# o Allow opening and exporting without a camera connected +# o webcam support (pygame, win and linux only) +# o notify export ending running_from_folder = os.path.realpath(__file__) alphabet = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'] @@ -116,7 +116,7 @@ class KISStopmo(tk.Tk): # Default config # Set script settings according to config file self.onion_skin = project_settings['onion_skin_onstartup'] - self.onionskin_alpha = project_settings['onionskin_alpha_default'] + self.onionskin_alpha_default = project_settings['onionskin_alpha_default'] self.onionskin_fx = project_settings['onionskin_fx'] self.fullscreen_bool = project_settings['fullscreen_bool'] self.screen_w, self.screen_h = project_settings['screen_w'], project_settings['screen_h'] @@ -174,7 +174,7 @@ class KISStopmo(tk.Tk): if image: if self.onion_skin: if self.img_index: - photo = self.apply_onionskin(image, self.onionskin_alpha, self.onionskin_fx) + photo = self.apply_onionskin(image, self.onionskin_alpha_default, self.onionskin_fx) else: photo = ImageTk.PhotoImage(image) @@ -347,17 +347,19 @@ class KISStopmo(tk.Tk): if file not in file_list: self.img_list.pop(file) - # TODO : check this works with new workflow - def batch_rename(self, folder:str): + + def batch_rename(self, folder:str): # initialize counter to 0 frame_list = self.get_frames_list(folder) counter = (".%04i." % x for x in count(0)) # ~ for i in range(len(frame_list)): + # ~ print(frame_list) for i in frame_list.keys(): # ~ if os.path.exists(os.path.realpath(frame_list[i])): - if os.path.exists(os.path.realpath(i)): + if os.path.exists(os.path.join(folder, i)): # ~ os.rename(os.path.realpath(frame_list[i]), os.path.realpath("{}{}{}".format(project_settings['project_letter'], next(counter), project_settings['file_extension']))) - os.rename(os.path.realpath(i), os.path.realpath("{}{}{}".format(self.project_letter, next(counter), project_settings['file_extension']))) + os.rename(os.path.join(folder, i), os.path.join(folder, "{}{}{}".format(self.project_letter, next(counter), project_settings['file_extension']))) + # ~ print(os.path.join(folder, "{}{}{}".format(self.project_letter, next(counter), project_settings['file_extension']))) else: print(_("{} does not exist").format(str(i))) return self.get_frames_list(folder) @@ -372,14 +374,14 @@ class KISStopmo(tk.Tk): self.img_list[list(self.img_list.keys())[i]] = None - # FIXME: Does this still work ? def remove_frame(self, event): if len(list(self.img_list.items())): folder_path = os.path.realpath(self.savepath) frame_name = list(self.img_list.items())[self.img_index][0] - frame_path = os.path.realpath(frame_name) - + # ~ frame_path = os.path.realpath(frame_name) + frame_path = os.path.join(folder_path, frame_name) + if not os.path.exists(frame_path): return 0 @@ -470,20 +472,18 @@ class KISStopmo(tk.Tk): index = self.check_range(self.img_index) if len(list(self.img_list.items())): # TODO: better approach + # If name == X.-001.JPG, we don't have any frame yet, so display splashscreen if list(self.img_list.items())[index][0] == "{}.{:04d}.{}".format(self.project_letter, -1, project_settings['file_extension']): new_image = self.splashscreen else: new_image = self.open_jpg(list(self.img_list.items())[index], project_settings['screen_w'], project_settings['screen_h'], project_settings['vflip'], project_settings['hflip']) else: new_image = self.splashscreen - # ~ return False - # ~ print(new_image) - # ~ new_image = self.open_jpg(self.img_list[index], self.screen_w, self.screen_h) if new_image: photo = ImageTk.PhotoImage(new_image) if self.onion_skin: if index: - photo = self.apply_onionskin(new_image, project_settings['onionskin_alpha'], project_settings['onionskin_fx']) + photo = self.apply_onionskin(new_image, project_settings['onionskin_alpha_default'], project_settings['onionskin_fx']) # ~ print(photo) self.label.configure(image=photo) self.label.image = photo