MCPcopy Create free account
hub / github.com/matplotlib/matplotlib / make_pdf_to_png_converter

Function make_pdf_to_png_converter

lib/matplotlib/backends/backend_pgf.py:169–193  ·  view source on GitHub ↗

Return a function that converts a pdf file to a png file.

()

Source from the content-addressed store, hash-verified

167
168
169def make_pdf_to_png_converter():
170 """Return a function that converts a pdf file to a png file."""
171 try:
172 mpl._get_executable_info("pdftocairo")
173 except mpl.ExecutableNotFoundError:
174 pass
175 else:
176 return lambda pdffile, pngfile, dpi: subprocess.check_output(
177 ["pdftocairo", "-singlefile", "-transp", "-png", "-r", "%d" % dpi,
178 pdffile, os.path.splitext(pngfile)[0]],
179 stderr=subprocess.STDOUT)
180 try:
181 gs_info = mpl._get_executable_info("gs")
182 except mpl.ExecutableNotFoundError:
183 pass
184 else:
185 return lambda pdffile, pngfile, dpi: subprocess.check_output(
186 [gs_info.executable,
187 '-dQUIET', '-dSAFER', '-dBATCH', '-dNOPAUSE', '-dNOPROMPT',
188 '-dUseCIEColor', '-dTextAlphaBits=4',
189 '-dGraphicsAlphaBits=4', '-dDOINTERPOLATE',
190 '-sDEVICE=pngalpha', '-sOutputFile=%s' % pngfile,
191 '-r%d' % dpi, pdffile],
192 stderr=subprocess.STDOUT)
193 raise RuntimeError("No suitable pdf to png renderer found.")
194
195
196class LatexError(Exception):

Callers 1

print_pngMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…