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

Skip to content

Commit 92a33aa

Browse files
committed
Skip None entries in png metadata.
1 parent 83f82f2 commit 92a33aa

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

lib/matplotlib/backends/backend_agg.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,8 +484,8 @@ def print_png(self, filename_or_obj, *args,
484484
485485
Other keywords may be invented for other purposes.
486486
487-
If 'Software' is not given, an autogenerated value for matplotlib
488-
will be used.
487+
If 'Software' is not given, an autogenerated value for Matplotlib
488+
will be used. This can be removed by setting it to *None*.
489489
490490
For more details see the `PNG specification`_.
491491

lib/matplotlib/image.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1543,7 +1543,8 @@ def imsave(fname, arr, vmin=None, vmax=None, cmap=None, format=None,
15431543
}
15441544
pil_kwargs["pnginfo"] = pnginfo = PIL.PngImagePlugin.PngInfo()
15451545
for k, v in metadata.items():
1546-
pnginfo.add_text(k, v)
1546+
if v is not None:
1547+
pnginfo.add_text(k, v)
15471548
if format in ["jpg", "jpeg"]:
15481549
format = "jpeg" # Pillow doesn't recognize "jpg".
15491550
facecolor = mpl.rcParams["savefig.facecolor"]

0 commit comments

Comments
 (0)