From 57a26fabcb9833903862366ba34efccc290b3177 Mon Sep 17 00:00:00 2001 From: Vinayak Mehta Date: Fri, 16 Oct 2020 16:11:10 +0530 Subject: [PATCH] Add pdftopng --- camelot/parsers/lattice.py | 11 ++---- setup.py | 70 +++++++++++++++++++------------------- 2 files changed, 37 insertions(+), 44 deletions(-) diff --git a/camelot/parsers/lattice.py b/camelot/parsers/lattice.py index 3fd5bbe..6b19efe 100644 --- a/camelot/parsers/lattice.py +++ b/camelot/parsers/lattice.py @@ -208,17 +208,10 @@ class Lattice(BaseParser): return t def _generate_image(self): - from ..ext.ghostscript import Ghostscript + from pdftopng import pdftopng self.imagename = "".join([self.rootname, ".png"]) - gs_call = "-q -sDEVICE=png16m -o {} -r{} {}".format( - self.imagename, self.resolution, self.filename - ) - gs_call = gs_call.encode().split() - null = open(os.devnull, "wb") - with Ghostscript(*gs_call, stdout=null) as gs: - pass - null.close() + pdftopng.convert(pdf_path=self.filename, png_path=self.rootname) def _generate_table_bbox(self): def scale_areas(areas): diff --git a/setup.py b/setup.py index 4ac7e0a..b883d5b 100644 --- a/setup.py +++ b/setup.py @@ -24,7 +24,10 @@ requires = [ "tabulate>=0.8.9", ] -cv_requires = ["opencv-python>=3.4.2.17"] +base_requires = [ + 'opencv-python>=3.4.2.17', + 'pdftopng>=0.1.0' +] plot_requires = [ "matplotlib>=2.2.3", @@ -40,44 +43,41 @@ dev_requires = [ "sphinx-autobuild>=2021.3.14", ] -all_requires = cv_requires + plot_requires +all_requires = base_requires + plot_requires dev_requires = dev_requires + all_requires def setup_package(): - metadata = dict( - name=about["__title__"], - version=about["__version__"], - description=about["__description__"], - long_description=readme, - long_description_content_type="text/markdown", - url=about["__url__"], - author=about["__author__"], - author_email=about["__author_email__"], - license=about["__license__"], - packages=find_packages(exclude=("tests",)), - install_requires=requires, - extras_require={ - "all": all_requires, - "cv": cv_requires, - "dev": dev_requires, - "plot": plot_requires, - }, - entry_points={ - "console_scripts": [ - "camelot = camelot.cli:cli", - ], - }, - classifiers=[ - # Trove classifiers - # Full list: https://pypi.python.org/pypi?%3Aaction=list_classifiers - "License :: OSI Approved :: MIT License", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - ], - ) + metadata = dict(name=about['__title__'], + version=about['__version__'], + description=about['__description__'], + long_description=readme, + long_description_content_type="text/markdown", + url=about['__url__'], + author=about['__author__'], + author_email=about['__author_email__'], + license=about['__license__'], + packages=find_packages(exclude=('tests',)), + install_requires=requires, + extras_require={ + 'all': all_requires, + 'base': base_requires, + 'dev': dev_requires, + 'plot': plot_requires + }, + entry_points={ + 'console_scripts': [ + 'camelot = camelot.cli:cli', + ], + }, + classifiers=[ + # Trove classifiers + # Full list: https://pypi.python.org/pypi?%3Aaction=list_classifiers + 'License :: OSI Approved :: MIT License', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8' + ]) try: from setuptools import setup