Skip to content

Commit

Permalink
fix parse error of some documents by using gs
Browse files Browse the repository at this point in the history
  • Loading branch information
JensPfeifle committed Mar 3, 2019
1 parent 3db98fa commit 0220199
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/paperless_tesseract/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,23 @@ def get_thumbnail(self):
"""

out_path = os.path.join(self.tempdir, "convert.png")
gs_out_path = os.path.join(self.tempdir, "gs_out.png")

# Run convert to get a decent thumbnail

# https://github.com/danielquinn/paperless/issues/447
# call gs first
environment = os.environ.copy()
cmd = ["gs", "-q", "-sDEVICE=pngalpha",
"-o", gs_out_path, self.document_path]
if not subprocess.Popen(cmd, env=environment).wait() == 0:
raise ParseError("Thumbnail (gs) failed at {}".format(cmd))
# then run convert on the output from gs
run_convert(
self.CONVERT,
"-scale", "500x5000",
"-alpha", "remove",
"{}[0]".format(self.document_path),
"gs_out_path",
out_path
)

Expand Down

0 comments on commit 0220199

Please sign in to comment.