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

Skip to content

Commit a490278

Browse files
committed
Update PngInfo.
1 parent 3da7fc4 commit a490278

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/matplotlib/colors.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
from PIL import Image
7676
from PIL.PngImagePlugin import PngInfo
7777

78+
import matplotlib as mpl
7879
import numpy as np
7980
import matplotlib.cbook as cbook
8081
from matplotlib import docstring
@@ -701,7 +702,13 @@ def _repr_png_(self):
701702
X = np.tile(np.linspace(0, 1, IMAGE_SIZE[0]), (IMAGE_SIZE[1], 1))
702703
pixels = self(X, bytes=True)
703704
png_bytes = io.BytesIO()
704-
pnginfo = PngInfo().add_text('name', self.name)
705+
title = self.name + ' color map'
706+
author = f'Matplotlib v{mpl.__version__}, https://matplotlib.org'
707+
pnginfo = PngInfo()
708+
pnginfo.add_text('Title', title)
709+
pnginfo.add_text('Description', title)
710+
pnginfo.add_text('Author', author)
711+
pnginfo.add_text('Software', author)
705712
Image.fromarray(pixels).save(png_bytes, format='png', pnginfo=pnginfo)
706713
return png_bytes.getvalue()
707714

0 commit comments

Comments
 (0)