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

Skip to content

Commit e9891e2

Browse files
committed
In imsave, let pnginfo have precedence over metadata.
This is consistent with the documented behavior ("If the 'pnginfo' key is present, it completely overrides *metadata*, including the default 'Software' key.") and also with the behavior of FigureCanvasAgg.print_png.
1 parent 4616897 commit e9891e2

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/matplotlib/image.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1539,7 +1539,8 @@ def imsave(fname, arr, vmin=None, vmax=None, cmap=None, format=None,
15391539
pil_shape = (rgba.shape[1], rgba.shape[0])
15401540
image = Image.frombuffer(
15411541
"RGBA", pil_shape, rgba, "raw", "RGBA", 0, 1)
1542-
if format == "png" and metadata is not None:
1542+
if (format == "png"
1543+
and metadata is not None and "pnginfo" not in pil_kwargs):
15431544
# cf. backend_agg's print_png.
15441545
pnginfo = PngInfo()
15451546
for k, v in metadata.items():

0 commit comments

Comments
 (0)