Commit f1677a7
committed
Composite against white, not the savefig.facecolor rc, in print_jpeg.
jpeg doesn't support alpha transparency, so we need to paste the image
against some solid background before saving it. Pasting against the
savefig.facecolor rc, as the code did before, is just wrong: it makes
e.g.
```
plot([1, 2])
rcParams["savefig.facecolor"] = "blue"
savefig("/tmp/foo.jpg", facecolor=(1, 0, 0, .5))
```
result in a purple background (blue + 0.5 red), instead of a red one (as
for png -- the facecolor kwarg should just override the rcParam).
Likewise the test_jpeg_alpha test was just wrong (indeed, trying to run
the same code but saving as png shows that transparent=True should
override the savefig.facecolor rcParam).
Instead, paste the image against a white background, which fixes the
issues (and is tested by the fixed test_jpeg_alpha).1 parent d576e3a commit f1677a7
2 files changed
Lines changed: 4 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
584 | 584 | | |
585 | 585 | | |
586 | 586 | | |
587 | | - | |
588 | | - | |
| 587 | + | |
| 588 | + | |
589 | 589 | | |
590 | | - | |
591 | | - | |
592 | | - | |
| 590 | + | |
593 | 591 | | |
594 | 592 | | |
595 | 593 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
674 | 674 | | |
675 | 675 | | |
676 | 676 | | |
677 | | - | |
678 | | - | |
| 677 | + | |
679 | 678 | | |
680 | 679 | | |
681 | 680 | | |
| |||
0 commit comments