| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1653,6 +1653,9 @@ def imsave(fname, arr, vmin=None, vmax=None, cmap=None, format=None, | |||
| 1653 | 1653 | rgba = sm.to_rgba(arr, bytes=True) | |
| 1654 | 1654 | if pil_kwargs is None: | |
| 1655 | 1655 | pil_kwargs = {} | |
| 1656 | + else: | ||
| 1657 | + # we modify this below, so make a copy (don't modify caller's dict) | ||
| 1658 | + pil_kwargs = pil_kwargs.copy() | ||
| 1656 | 1659 | pil_shape = (rgba.shape[1], rgba.shape[0]) | |
| 1657 | 1660 | image = PIL.Image.frombuffer( | |
| 1658 | 1661 | "RGBA", pil_shape, rgba, "raw", "RGBA", 0, 1) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -254,9 +254,11 @@ def test_pil_kwargs_webp(): | |||
| 254 | 254 | buf_small = io.BytesIO() | |
| 255 | 255 | pil_kwargs_low = {"quality": 1} | |
| 256 | 256 | plt.savefig(buf_small, format="webp", pil_kwargs=pil_kwargs_low) | |
| 257 | + assert len(pil_kwargs_low) == 1 | ||
| 257 | 258 | buf_large = io.BytesIO() | |
| 258 | 259 | pil_kwargs_high = {"quality": 100} | |
| 259 | 260 | plt.savefig(buf_large, format="webp", pil_kwargs=pil_kwargs_high) | |
| 261 | + assert len(pil_kwargs_high) == 1 | ||
| 260 | 262 | assert buf_large.getbuffer().nbytes > buf_small.getbuffer().nbytes | |
| 261 | 263 | ||
| 262 | 264 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -249,6 +249,7 @@ def test_imsave_pil_kwargs_tiff(): | |||
| 249 | 249 | buf = io.BytesIO() | |
| 250 | 250 | pil_kwargs = {"description": "test image"} | |
| 251 | 251 | plt.imsave(buf, [[0, 1], [2, 3]], format="tiff", pil_kwargs=pil_kwargs) | |
| 252 | + assert len(pil_kwargs) == 1 | ||
| 252 | 253 | im = Image.open(buf) | |
| 253 | 254 | tags = {TAGS[k].name: v for k, v in im.tag_v2.items()} | |
| 254 | 255 | assert tags["ImageDescription"] == "test image" | |
| Back | FazBrowse Home | New Git URL |
0 commit comments