Replace imagemagick with ghostscript

* Replace imagemagick with ghostscript

* Add quiet option

* Avoid repetition

* Remove Wand requirement

* Replace jpeg with png
This commit is contained in:
Vinayak Mehta
2016-09-13 17:35:07 +05:30
committed by GitHub
parent 757ba0444a
commit 8ce7b74671
3 changed files with 12 additions and 8 deletions
+11 -6
View File
@@ -1,10 +1,9 @@
from __future__ import division from __future__ import division
import os import os
import types import types
import copy_reg
import logging import logging
import copy_reg
from wand.image import Image import subprocess
from .imgproc import (adaptive_threshold, find_lines, find_table_contours, from .imgproc import (adaptive_threshold, find_lines, find_table_contours,
find_table_joints) find_table_joints)
@@ -91,9 +90,15 @@ class Lattice:
os.path.basename(bname))) os.path.basename(bname)))
return None return None
imagename = ''.join([bname, '.png']) imagename = ''.join([bname, '.jpg'])
with Image(filename=pdfname, depth=8, resolution=300) as png: gs_call = [
png.save(filename=imagename) "-q", "-sDEVICE=png16m", "-o", imagename, "-r600", pdfname
]
if "ghostscript" in subprocess.check_output(["gs", "-version"]).lower():
gs_call.insert(0, "gs")
else:
gs_call.insert(0, "gsc")
subprocess.call(gs_call)
img, threshold = adaptive_threshold(imagename, invert=self.invert) img, threshold = adaptive_threshold(imagename, invert=self.invert)
pdf_x = width pdf_x = width
+1 -1
View File
@@ -1,8 +1,8 @@
from __future__ import division from __future__ import division
import os import os
import types import types
import copy_reg
import logging import logging
import copy_reg
import numpy as np import numpy as np
-1
View File
@@ -5,4 +5,3 @@ pdfminer
pyexcel-xlsx pyexcel-xlsx
PyPDF2 PyPDF2
Sphinx Sphinx
Wand