Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions lib/matplotlib/backends/backend_agg.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,12 +584,10 @@ def print_jpg(self, filename_or_obj, *args, dryrun=False,
FigureCanvasAgg.draw(self)
if dryrun:
return
# The image is "pasted" onto a white background image to safely
# handle any transparency
# The image is pasted onto a white background image to handle
# transparency.
image = Image.fromarray(np.asarray(self.buffer_rgba()))
rgba = mcolors.to_rgba(rcParams['savefig.facecolor'])
color = tuple([int(x * 255) for x in rgba[:3]])
background = Image.new('RGB', image.size, color)
background = Image.new('RGB', image.size, "white")
background.paste(image, image)
if pil_kwargs is None:
pil_kwargs = {}
Expand Down
3 changes: 1 addition & 2 deletions lib/matplotlib/tests/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -674,8 +674,7 @@ def test_jpeg_alpha():
plt.figimage(im)

buff = io.BytesIO()
with rc_context({'savefig.facecolor': 'red'}):
plt.savefig(buff, transparent=True, format='jpg', dpi=300)
plt.savefig(buff, facecolor="red", format='jpg', dpi=300)

buff.seek(0)
image = Image.open(buff)
Expand Down