Skip to content

Commit 5d593ea

Browse files
committed
1 parent 842435f commit 5d593ea

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

lib/matplotlib/testing/compare.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import numpy as np
1919
from PIL import Image
20+
import packaging.version
2021

2122
import matplotlib as mpl
2223
from matplotlib import cbook
@@ -56,7 +57,7 @@ def get_file_hash(path, block_size=2 ** 20):
5657

5758
if Path(path).suffix == '.pdf':
5859
sha256.update(str(mpl._get_executable_info("gs").version).encode('utf-8'))
59-
sha256.update(b"r600") # invalidate old cache entries
60+
sha256.update(b"antialiasing") # invalidate old cache entries
6061
elif Path(path).suffix == '.svg':
6162
sha256.update(str(mpl._get_executable_info("inkscape").version).encode('utf-8'))
6263

@@ -111,14 +112,21 @@ def __call__(self, orig, dest):
111112
class _GSConverter(_Converter):
112113
def __call__(self, orig, dest):
113114
if not self._proc:
115+
if mpl._get_executable_info("gs").version < packaging.version.parse("9.57"):
116+
antialias = [
117+
"-sDEVICE=png16m",
118+
"-r150",
119+
"-dGraphicsAlphaBits=4",
120+
"-dTextAlphaBits=4",
121+
]
122+
else:
123+
antialias = ["-sDEVICE=png16malpha", "-r600", "-dDownScaleFactor=4"]
114124
self._proc = subprocess.Popen(
115125
[mpl._get_executable_info("gs").executable,
116126
"-dNOSAFER",
117127
"-dNOPAUSE",
118128
"-dEPSCrop",
119-
"-sDEVICE=png16malpha",
120-
"-r600",
121-
"-dDownScaleFactor=4"],
129+
*antialias],
122130
# As far as I can see, ghostscript never outputs to stderr.
123131
stdin=subprocess.PIPE, stdout=subprocess.PIPE)
124132
try:

0 commit comments

Comments
 (0)