Call pdftopng in subprocess

This commit is contained in:
Vinayak Mehta
2021-07-04 18:52:38 +05:30
parent 4c32c45534
commit 4dd1e7fb15
4 changed files with 27 additions and 37 deletions
+2 -2
View File
@@ -35,7 +35,7 @@ class GhostscriptBackend(object):
"here: https://camelot-py.readthedocs.io/en/master/user/install-deps.html"
)
gs_args = [
gs_command = [
"gs",
"-q",
"-sDEVICE=png16m",
@@ -44,4 +44,4 @@ class GhostscriptBackend(object):
f"-r{resolution}",
pdf_path,
]
ghostscript.Ghostscript(*gs_args)
ghostscript.Ghostscript(*gs_command)
+9 -2
View File
@@ -1,8 +1,15 @@
# -*- coding: utf-8 -*-
from pdftopng import pdftopng
import subprocess
class PopplerBackend(object):
def convert(self, pdf_path, png_path):
pdftopng.convert(pdf_path, png_path)
pdftopng_command = ["pdftopng", pdf_path, png_path]
try:
subprocess.check_output(
" ".join(pdftopng_command), stderr=subprocess.STDOUT, shell=True
)
except subprocess.CalledProcessError as e:
raise ValueError(e.output)