Use optipng to optimise document thumbnails

This commit is contained in:
Daniel Quinn
2018-10-07 14:56:38 +01:00
parent 074609e1fc
commit bc898c1992
9 changed files with 85 additions and 22 deletions

View File

@@ -44,15 +44,18 @@ class RasterisedDocumentParser(DocumentParser):
The thumbnail of a PDF is just a 500px wide image of the first page.
"""
out_path = os.path.join(self.tempdir, "convert.png")
# Run convert to get a decent thumbnail
run_convert(
self.CONVERT,
"-scale", "500x5000",
"-alpha", "remove",
"{}[0]".format(self.document_path),
os.path.join(self.tempdir, "convert.png")
out_path
)
return os.path.join(self.tempdir, "convert.png")
return out_path
def _is_ocred(self):