|
17 | 17 |
|
18 | 18 | import numpy as np
|
19 | 19 | from PIL import Image
|
| 20 | +import packaging.version |
20 | 21 |
|
21 | 22 | import matplotlib as mpl
|
22 | 23 | from matplotlib import cbook
|
@@ -56,7 +57,7 @@ def get_file_hash(path, block_size=2 ** 20):
|
56 | 57 |
|
57 | 58 | if Path(path).suffix == '.pdf':
|
58 | 59 | 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 |
60 | 61 | elif Path(path).suffix == '.svg':
|
61 | 62 | sha256.update(str(mpl._get_executable_info("inkscape").version).encode('utf-8'))
|
62 | 63 |
|
@@ -111,14 +112,21 @@ def __call__(self, orig, dest):
|
111 | 112 | class _GSConverter(_Converter):
|
112 | 113 | def __call__(self, orig, dest):
|
113 | 114 | 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"] |
114 | 124 | self._proc = subprocess.Popen(
|
115 | 125 | [mpl._get_executable_info("gs").executable,
|
116 | 126 | "-dNOSAFER",
|
117 | 127 | "-dNOPAUSE",
|
118 | 128 | "-dEPSCrop",
|
119 |
| - "-sDEVICE=png16malpha", |
120 |
| - "-r600", |
121 |
| - "-dDownScaleFactor=4"], |
| 129 | + *antialias], |
122 | 130 | # As far as I can see, ghostscript never outputs to stderr.
|
123 | 131 | stdin=subprocess.PIPE, stdout=subprocess.PIPE)
|
124 | 132 | try:
|
|
0 commit comments