Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions manimlib/scene/scene_file_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import _thread as thread
from time import sleep
import datetime
from PIL import Image

import manimlib.constants as consts
from manimlib.constants import FFMPEG_BIN
Expand Down Expand Up @@ -37,7 +38,6 @@ class SceneFileWriter(object):
"""
CONFIG = {
"write_to_movie": False,
# TODO, save_pngs is doing nothing
"save_pngs": False,
"png_mode": "RGBA",
"save_last_frame": False,
Expand All @@ -56,6 +56,7 @@ def __init__(self, scene, **kwargs):
self.stream_lock = False
self.init_output_directories()
self.init_audio()
self.frame_count = 0

# Output directories and files
def init_output_directories(self):
Expand All @@ -66,7 +67,7 @@ def init_output_directories(self):
"""
module_directory = self.output_directory or self.get_default_module_directory()
scene_name = self.file_name or self.get_default_scene_name()
if self.save_last_frame:
if self.save_last_frame or self.save_pngs:
if consts.VIDEO_DIR != "":
image_dir = guarantee_existence(os.path.join(
consts.VIDEO_DIR,
Expand Down Expand Up @@ -334,6 +335,10 @@ def write_frame(self, frame):
"""
if self.write_to_movie:
self.writing_process.stdin.write(frame.tostring())
if self.save_pngs:
path, extension = os.path.splitext(self.image_file_path)
Image.fromarray(frame).save(f'{path}{self.frame_count}{extension}')
self.frame_count += 1

def save_final_image(self, image):
"""
Expand Down