Create save subdirectories before writing
This commit is contained in:
@@ -383,6 +383,7 @@ class DumasSaveImageNode:
|
||||
sub_dirs = resolved_parts[:-1]
|
||||
filename = resolved_parts[-1] if resolved_parts else f"image_{str(counter).zfill(3)}{extension}"
|
||||
frame_dir = os.path.join(target_dir, *sub_dirs)
|
||||
os.makedirs(frame_dir, exist_ok=True)
|
||||
image = _tensor_image_to_pil_image(images[batch_index : batch_index + 1])
|
||||
full_path = os.path.join(frame_dir, filename)
|
||||
|
||||
|
||||
@@ -221,6 +221,23 @@ class DumasImageNodeTests(unittest.TestCase):
|
||||
saved_path = FakePILImage.saved_paths[0][0].replace("\\", "/")
|
||||
self.assertTrue(saved_path.endswith("/Char001/Char001.png"))
|
||||
|
||||
def test_save_image_creates_nested_directories_before_saving(self):
|
||||
node = self.image_nodes.DumasSaveImageNode()
|
||||
image = FakeTensorBatch()
|
||||
|
||||
node.save_images(
|
||||
images=image,
|
||||
folder=self.temp_dir,
|
||||
pattern="Char_%counter%/Base",
|
||||
format="png",
|
||||
quality=100,
|
||||
embed_workflow=False,
|
||||
save_on_run=True,
|
||||
)
|
||||
|
||||
saved_path = FakePILImage.saved_paths[0][0]
|
||||
self.assertTrue(os.path.isdir(os.path.dirname(saved_path)))
|
||||
|
||||
def test_save_image_returns_ui_entries_for_output_folder(self):
|
||||
node = self.image_nodes.DumasSaveImageNode()
|
||||
image = FakeTensorBatch()
|
||||
|
||||
Reference in New Issue
Block a user