mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
fix parse error of some documents by using gs
This commit is contained in:
parent
3db98faf5c
commit
0220199766
@ -45,13 +45,23 @@ class RasterisedDocumentParser(DocumentParser):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
out_path = os.path.join(self.tempdir, "convert.png")
|
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
|
# 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(
|
run_convert(
|
||||||
self.CONVERT,
|
self.CONVERT,
|
||||||
"-scale", "500x5000",
|
"-scale", "500x5000",
|
||||||
"-alpha", "remove",
|
"-alpha", "remove",
|
||||||
"{}[0]".format(self.document_path),
|
"gs_out_path",
|
||||||
out_path
|
out_path
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user