Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close opened plots to save memory and stop matplotlib from complaining #135

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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: 9 additions & 0 deletions nodes/nodes_graphics_matplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ def halftone(self, width, height, dot_style, reverse_dot_style, dot_frequency, b

img_buf = io.BytesIO()
plt.savefig(img_buf, format='png')
plt.close()
img = Image.open(img_buf)

image_out = pil2tensor(img.convert("RGB"))
Expand Down Expand Up @@ -253,6 +254,7 @@ def draw(self, mode, width, height, color_1, color_2,

img_buf = io.BytesIO()
plt.savefig(img_buf, format='png')
plt.close()
img = Image.open(img_buf)

image_out = pil2tensor(img.convert("RGB"))
Expand Down Expand Up @@ -323,6 +325,7 @@ def draw(self, mode, width, height, bar_style, orientation, bar_frequency):

img_buf = io.BytesIO()
plt.savefig(img_buf, format='png')
plt.close()
img = Image.open(img_buf)

image_out = pil2tensor(img.convert("RGB"))
Expand Down Expand Up @@ -420,6 +423,7 @@ def get_gradient_value(pos, length, linear_transition, gradient_distance): #gett

img_buf = io.BytesIO()
plt.savefig(img_buf, format='png')
plt.close()
img = Image.open(img_buf)

image_out = pil2tensor(img.convert("RGB"))
Expand Down Expand Up @@ -494,6 +498,7 @@ def draw(self, width, height, start_color, end_color,

img_buf = io.BytesIO()
plt.savefig(img_buf, format='png')
plt.close()
img = Image.open(img_buf)

image_out = pil2tensor(img.convert("RGB"))
Expand Down Expand Up @@ -574,6 +579,7 @@ def draw(self, mode, width, height, color_1, color_2,

img_buf = io.BytesIO()
plt.savefig(img_buf, format='png')
plt.close()
img = Image.open(img_buf)

image_out = pil2tensor(img.convert("RGB"))
Expand Down Expand Up @@ -661,6 +667,7 @@ def draw(self, mode, width, height, rows, columns,

img_buf = io.BytesIO()
plt.savefig(img_buf, format='png')
plt.close()
img = Image.open(img_buf)

image_out = pil2tensor(img.convert("RGB"))
Expand Down Expand Up @@ -743,6 +750,7 @@ def draw(self, width, height, num_lines, line_length, line_width, line_color, ba

img_buf = io.BytesIO()
plt.savefig(img_buf, format='png')
plt.close()
img = Image.open(img_buf)

image_out = pil2tensor(img.convert("RGB"))
Expand Down Expand Up @@ -838,6 +846,7 @@ def draw(self, width, height, num_triangles, color_1, color_2,

img_buf = io.BytesIO()
plt.savefig(img_buf, format='png')
plt.close()
img = Image.open(img_buf)

image_out = pil2tensor(img.convert("RGB"))
Expand Down