mirror of
https://github.com/3b1b/manim.git
synced 2025-07-30 13:34:19 +08:00
Fixed problem with output_directory_getters.py on new files
This commit is contained in:
@ -21,6 +21,7 @@ HELP_MESSAGE = """
|
|||||||
-p preview in low quality
|
-p preview in low quality
|
||||||
-s show and save picture of last frame
|
-s show and save picture of last frame
|
||||||
-w write result to file [this is default if nothing else is stated]
|
-w write result to file [this is default if nothing else is stated]
|
||||||
|
-o <file_name> write to a different file_name
|
||||||
-l use low quality
|
-l use low quality
|
||||||
-m use medium quality
|
-m use medium quality
|
||||||
-a run and save every scene in the script, or all args for the given scene
|
-a run and save every scene in the script, or all args for the given scene
|
||||||
|
@ -545,9 +545,6 @@ class Scene(Container):
|
|||||||
|
|
||||||
def save_image(self, name=None, mode="RGB", dont_update=False):
|
def save_image(self, name=None, mode="RGB", dont_update=False):
|
||||||
path = self.get_image_file_path(name, dont_update)
|
path = self.get_image_file_path(name, dont_update)
|
||||||
directory_path = os.path.dirname(path)
|
|
||||||
if not os.path.exists(directory_path):
|
|
||||||
os.makedirs(directory_path)
|
|
||||||
if not dont_update:
|
if not dont_update:
|
||||||
self.update_frame(dont_update_when_skipping=False)
|
self.update_frame(dont_update_when_skipping=False)
|
||||||
image = self.get_image()
|
image = self.get_image()
|
||||||
|
@ -12,6 +12,12 @@ def add_extension_if_not_present(file_name, extension):
|
|||||||
return file_name
|
return file_name
|
||||||
|
|
||||||
|
|
||||||
|
def guarantee_existance(path):
|
||||||
|
if not os.path.exists(path):
|
||||||
|
os.makedirs(path)
|
||||||
|
return path
|
||||||
|
|
||||||
|
|
||||||
def get_scene_output_directory(scene_class):
|
def get_scene_output_directory(scene_class):
|
||||||
file_path = os.path.abspath(inspect.getfile(scene_class))
|
file_path = os.path.abspath(inspect.getfile(scene_class))
|
||||||
|
|
||||||
@ -22,7 +28,7 @@ def get_scene_output_directory(scene_class):
|
|||||||
file_path = os.path.join(*sub_parts)
|
file_path = os.path.join(*sub_parts)
|
||||||
file_path = file_path.replace(".pyc", "")
|
file_path = file_path.replace(".pyc", "")
|
||||||
file_path = file_path.replace(".py", "")
|
file_path = file_path.replace(".py", "")
|
||||||
return os.path.join(ANIMATIONS_DIR, file_path)
|
return guarantee_existance(os.path.join(ANIMATIONS_DIR, file_path))
|
||||||
|
|
||||||
|
|
||||||
def get_movie_output_directory(scene_class, camera_config, frame_duration):
|
def get_movie_output_directory(scene_class, camera_config, frame_duration):
|
||||||
@ -31,8 +37,9 @@ def get_movie_output_directory(scene_class, camera_config, frame_duration):
|
|||||||
camera_config["pixel_shape"][0],
|
camera_config["pixel_shape"][0],
|
||||||
int(1.0 / frame_duration)
|
int(1.0 / frame_duration)
|
||||||
)
|
)
|
||||||
return os.path.join(directory, sub_dir)
|
return guarantee_existance(os.path.join(directory, sub_dir))
|
||||||
|
|
||||||
|
|
||||||
def get_image_output_directory(scene_class, sub_dir="images"):
|
def get_image_output_directory(scene_class, sub_dir="images"):
|
||||||
return os.path.join(get_scene_output_directory(scene_class), sub_dir)
|
directory = get_scene_output_directory(scene_class)
|
||||||
|
return guarantee_existance(os.path.join(directory, sub_dir))
|
||||||
|
Reference in New Issue
Block a user