Improve sorting by date in ImageDrawer
This ensures that, if available, we'll sort using the date the file was created rather than modified date. Modified will be used as a fallback.
This commit is contained in:
@@ -118,7 +118,7 @@ def create_familiar_dictionaries(names, type, image_extension_filter, info_exten
|
||||
# logger.info(f"file_name_no_ext, file_ext: {file_name_no_ext, file_ext}")
|
||||
|
||||
# Get time of creation since the last epoch, in seconds
|
||||
file_age = os.path.getctime(file_path)
|
||||
file_age = get_creation_time(file_path)
|
||||
|
||||
file_path = file_path.replace("\\", "/")
|
||||
# logger.info(f'file_path: {file_path}')
|
||||
|
||||
@@ -389,3 +389,11 @@ def is_pil_image(obj):
|
||||
# Check if an object is a PyTorch tensor
|
||||
def is_torch_tensor(obj):
|
||||
return isinstance(obj, torch.Tensor)
|
||||
|
||||
def get_creation_time(file_path):
|
||||
"""Get file creation time if available, otherwise fallback to modification time."""
|
||||
try:
|
||||
stat = os.stat(file_path)
|
||||
return stat.st_birthtime # Works on some Linux filesystems
|
||||
except AttributeError:
|
||||
return os.path.getmtime(file_path)
|
||||
|
||||
Reference in New Issue
Block a user