Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3da7fc4

Browse files
committed
Add PngInfo.
1 parent 34be66e commit 3da7fc4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/matplotlib/colors.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
from numbers import Number
7474
import re
7575
from PIL import Image
76+
from PIL.PngImagePlugin import PngInfo
7677

7778
import numpy as np
7879
import matplotlib.cbook as cbook
@@ -700,7 +701,8 @@ def _repr_png_(self):
700701
X = np.tile(np.linspace(0, 1, IMAGE_SIZE[0]), (IMAGE_SIZE[1], 1))
701702
pixels = self(X, bytes=True)
702703
png_bytes = io.BytesIO()
703-
Image.fromarray(pixels).save(png_bytes, format='png')
704+
pnginfo = PngInfo().add_text('name', self.name)
705+
Image.fromarray(pixels).save(png_bytes, format='png', pnginfo=pnginfo)
704706
return png_bytes.getvalue()
705707

706708
def _repr_html_(self):

0 commit comments

Comments
 (0)