Fix remove/rename frames

This commit is contained in:
ABelliqueux 2024-02-20 09:55:14 +01:00
parent 8338ccce4b
commit 8374c9370f
2 changed files with 18 additions and 18 deletions

View File

@ -10,7 +10,7 @@ fullscreen_bool = true
screen_w = 1920 screen_w = 1920
screen_h = 1080 screen_h = 1080
framerate = 16 framerate = 16
vflip = true vflip = false
hflip = false hflip = false
export_options = 'scale=1920:-1,crop=1920:1080:0:102' export_options = 'scale=1920:-1,crop=1920:1080:0:102'
[CAMERA] [CAMERA]

View File

@ -46,20 +46,20 @@ from send2trash import send2trash
# X wait event mode # X wait event mode
# X remove frames # X remove frames
# X keep images in memory (odict > list ?) # 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 project workflow
# X use a different folder for each project (A, B, C, etc...) # 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 : check for existing folder with name A, B, C, etc.
# X startup : offer to continue previous project or new project # 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 # 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 colored onion skin frame (pillow filters)
# X startup frame # X startup frame
# o webcam support (pygame, win and linux only)
# X Import config values from config file # X Import config values from config file
# X Translation # X Translation
# X Allow opening and exporting without a camera connected
# o Better settings names # 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__) 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'] 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 # Default config
# Set script settings according to config file # Set script settings according to config file
self.onion_skin = project_settings['onion_skin_onstartup'] 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.onionskin_fx = project_settings['onionskin_fx']
self.fullscreen_bool = project_settings['fullscreen_bool'] self.fullscreen_bool = project_settings['fullscreen_bool']
self.screen_w, self.screen_h = project_settings['screen_w'], project_settings['screen_h'] 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 image:
if self.onion_skin: if self.onion_skin:
if self.img_index: 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: else:
photo = ImageTk.PhotoImage(image) photo = ImageTk.PhotoImage(image)
@ -347,17 +347,19 @@ class KISStopmo(tk.Tk):
if file not in file_list: if file not in file_list:
self.img_list.pop(file) 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 # initialize counter to 0
frame_list = self.get_frames_list(folder) frame_list = self.get_frames_list(folder)
counter = (".%04i." % x for x in count(0)) counter = (".%04i." % x for x in count(0))
# ~ for i in range(len(frame_list)): # ~ for i in range(len(frame_list)):
# ~ print(frame_list)
for i in frame_list.keys(): for i in frame_list.keys():
# ~ if os.path.exists(os.path.realpath(frame_list[i])): # ~ 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(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: else:
print(_("{} does not exist").format(str(i))) print(_("{} does not exist").format(str(i)))
return self.get_frames_list(folder) return self.get_frames_list(folder)
@ -372,14 +374,14 @@ class KISStopmo(tk.Tk):
self.img_list[list(self.img_list.keys())[i]] = None self.img_list[list(self.img_list.keys())[i]] = None
# FIXME: Does this still work ?
def remove_frame(self, event): def remove_frame(self, event):
if len(list(self.img_list.items())): if len(list(self.img_list.items())):
folder_path = os.path.realpath(self.savepath) folder_path = os.path.realpath(self.savepath)
frame_name = list(self.img_list.items())[self.img_index][0] 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): if not os.path.exists(frame_path):
return 0 return 0
@ -470,20 +472,18 @@ class KISStopmo(tk.Tk):
index = self.check_range(self.img_index) index = self.check_range(self.img_index)
if len(list(self.img_list.items())): if len(list(self.img_list.items())):
# TODO: better approach # 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']): if list(self.img_list.items())[index][0] == "{}.{:04d}.{}".format(self.project_letter, -1, project_settings['file_extension']):
new_image = self.splashscreen new_image = self.splashscreen
else: 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']) 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: else:
new_image = self.splashscreen 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: if new_image:
photo = ImageTk.PhotoImage(new_image) photo = ImageTk.PhotoImage(new_image)
if self.onion_skin: if self.onion_skin:
if index: 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) # ~ print(photo)
self.label.configure(image=photo) self.label.configure(image=photo)
self.label.image = photo self.label.image = photo