Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Gave control of ''image'' subdirectory to Scene

Grant Sandersonc6e3db25294d
diff --git a/extract_scene.py b/extract_scene.py
index 71f6354d5..3376cc773 100644
--- a/extract_scene.py
+++ b/extract_scene.py
@@ -101,9 +101,7 @@ def handle_scene(scene, **config):
if config["save_image"]:
if not config["write_all"]:
scene.show_frame()
- path = os.path.join(MOVIE_DIR, config["movie_prefix"], "images")
- if not os.path.exists(path):
- os.makedirs(path)
+ path = os.path.join(MOVIE_DIR, config["movie_prefix"])
scene.save_image(path, name)
if config["write"]:
scene.write_to_movie(os.path.join(config["movie_prefix"], name))
diff --git a/scene/scene.py b/scene/scene.py
index 4a5fc8184..495767418 100644
--- a/scene/scene.py
+++ b/scene/scene.py
@@ -243,8 +243,12 @@ class Scene(object):
TkSceneRoot(self)
def save_image(self, directory = MOVIE_DIR, name = None):
- path = os.path.join(directory, name or str(self)) + ".png"
- Image.fromarray(self.get_frame()).save(path)
+ path = os.path.join(directory, "images")
+ file_name = (name or str(self)) + ".png"
+ full_path = os.path.join(path, file_name)
+ if not os.path.exists(path):
+ os.makedirs(path)
+ Image.fromarray(self.get_frame()).save(full_path)
# To list possible args that subclasses have
# Elements should always be a tuple