Allow changing the output format, DPI of the pdftoppm command, and

the output format of the converter via the CONVERTER_GRAPHICS_BACKEND_CONFIG
setting sub options: pdftoppm_dpi: 300, pdftoppm_format: jpeg, pillow_format: jpeg
GitHub issues #256 #257 GitLab issue #416.

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
Roberto Rosario
2017-08-03 01:04:49 -04:00
parent 790d606834
commit b6ffeaeb32
7 changed files with 62 additions and 14 deletions

View File

@@ -11,6 +11,9 @@
- Add workaround for pycountry versions without the bibliographical key.
GitHub issue #250.
- Skip UUID migration on Oracle backends. GitHub issue #251.
- Allow changing the output format, DPI of the pdftoppm command, and
the output format of the converter via the CONVERTER_GRAPHICS_BACKEND_CONFIG
setting. GitHub issues #256 #257 GitLab issue #416.
2.6.4 (2017-07-26)
==================

View File

@@ -23,7 +23,10 @@ Other Changes
- Add workaround for pycountry versions without the bibliographical key.
GitHub issue #250.
- Skip UUID migration on Oracle backends. GitHub issue #251.
- Allow changing the output format, DPI of the pdftoppm command, and
the output format of the converter via the CONVERTER_GRAPHICS_BACKEND_CONFIG
setting sub options: pdftoppm_dpi: 300, pdftoppm_format: jpeg, pillow_format: jpeg
GitHub issues #256 #257 GitLab issue #416.
Removals
--------
@@ -80,8 +83,11 @@ Bugs fixed or issues closed
* `GitHub issue #250 <https://github.com/mayan-edms/mayan-edms/issues/250>`_ migrate fails on documents.0025_auto_20150718_0742
* `GitHub issue #251 <https://github.com/mayan-edms/mayan-edms/issues/251>`_ migrate fails on documents.0032_auto_20160315_0537
* `GitHub issue #256 <https://github.com/mayan-edms/mayan-edms/issues/256>`_ Make it possible to adjust values in apps\converter\literals.py from Settings
* `GitHub issue #257 <https://github.com/mayan-edms/mayan-edms/issues/257>`_ Use the DEFAULT_FILE_FORMAT from literals.py in python.py
* `GitHub issue #261 <https://github.com/mayan-edms/mayan-edms/issues/261>`_ fix_orientation method causes document add to crash
* `GitHub issue #263 <https://github.com/mayan-edms/mayan-edms/issues/263>`_ Typo in mayan/apps/ocr/migrations/0004_documenttypesettings.py
* `GitLab issue #400 <https://gitlab.com/mayan-edms/mayan-edms/issues/400>`_ Django REST framework's BasicAuthentication doesn't work with Oauth2_proxy
* `GitLab issue #416 <https://gitlab.com/mayan-edms/mayan-edms/issues/416>`_ DPI value for OCR not taken from document metadata
* `GitLab issue #417 <https://gitlab.com/mayan-edms/mayan-edms/issues/400>`_ Display document cabinets in documents list
.. _PyPI: https://pypi.python.org/pypi/mayan-edms/

View File

@@ -1,4 +0,0 @@
from __future__ import unicode_literals
DEFAULT_PDFTOPPM_PATH = '/usr/bin/pdftoppm'
DEFAULT_PDFINFO_PATH = '/usr/bin/pdfinfo'

View File

@@ -23,7 +23,10 @@ from ..classes import ConverterBase
from ..exceptions import PageCountError
from ..settings import setting_graphics_backend_config
from .literals import DEFAULT_PDFTOPPM_PATH, DEFAULT_PDFINFO_PATH
from ..literals import (
DEFAULT_PDFTOPPM_DPI, DEFAULT_PDFTOPPM_FORMAT, DEFAULT_PDFTOPPM_PATH,
DEFAULT_PDFINFO_PATH
)
try:
pdftoppm = sh.Command(
@@ -34,7 +37,19 @@ try:
except sh.CommandNotFound:
pdftoppm = None
else:
pdftoppm = pdftoppm.bake('-jpeg')
pdftoppm_format = '-{}'.format(
yaml.load(setting_graphics_backend_config.value).get(
'pdftoppm_format', DEFAULT_PDFTOPPM_FORMAT
)
)
pdftoppm_dpi = format(
yaml.load(setting_graphics_backend_config.value).get(
'pdftoppm_dpi', DEFAULT_PDFTOPPM_DPI
)
)
pdftoppm = pdftoppm.bake(pdftoppm_format, '-r', pdftoppm_dpi)
try:
pdfinfo = sh.Command(

View File

@@ -21,7 +21,7 @@ from mimetype.api import get_mimetype
from .exceptions import InvalidOfficeFormat, OfficeConversionError
from .literals import (
DEFAULT_LIBREOFFICE_PATH, DEFAULT_PAGE_NUMBER, DEFAULT_FILE_FORMAT
DEFAULT_LIBREOFFICE_PATH, DEFAULT_PAGE_NUMBER, DEFAULT_PILLOW_FORMAT
)
from .settings import setting_graphics_backend_config
@@ -183,7 +183,13 @@ class ConverterBase(object):
fs_cleanup(input_filepath)
fs_cleanup(converted_output)
def get_page(self, output_format=DEFAULT_FILE_FORMAT, as_base64=False):
def get_page(self, output_format=None, as_base64=False):
output_format = output_format or yaml.load(
setting_graphics_backend_config.value
).get(
'pillow_format', DEFAULT_PILLOW_FORMAT
)
if not self.image:
self.seek(0)

View File

@@ -3,7 +3,12 @@ from __future__ import unicode_literals
DEFAULT_ZOOM_LEVEL = 100
DEFAULT_ROTATION = 0
DEFAULT_PAGE_NUMBER = 1
DEFAULT_FILE_FORMAT = 'JPEG'
DEFAULT_PILLOW_FORMAT = 'JPEG'
DEFAULT_LIBREOFFICE_PATH = '/usr/bin/libreoffice'
DEFAULT_PDFTOPPM_DPI = 300
DEFAULT_PDFTOPPM_FORMAT = 'jpeg' # Possible values jpeg, png, tiff
DEFAULT_PDFTOPPM_PATH = '/usr/bin/pdftoppm'
DEFAULT_PDFINFO_PATH = '/usr/bin/pdfinfo'
DIMENSION_SEPARATOR = 'x'

View File

@@ -4,6 +4,11 @@ from django.utils.translation import ugettext_lazy as _
from smart_settings import Namespace
from .literals import (
DEFAULT_LIBREOFFICE_PATH, DEFAULT_PDFTOPPM_DPI, DEFAULT_PDFTOPPM_FORMAT,
DEFAULT_PDFTOPPM_PATH, DEFAULT_PDFINFO_PATH, DEFAULT_PILLOW_FORMAT
)
namespace = Namespace(name='converter', label=_('Converter'))
setting_graphics_backend = namespace.add_setting(
default='converter.backends.python.Python',
@@ -11,9 +16,21 @@ setting_graphics_backend = namespace.add_setting(
global_name='CONVERTER_GRAPHICS_BACKEND',
)
setting_graphics_backend_config = namespace.add_setting(
default='{libreoffice_path: /usr/bin/libreoffice, '
'pdftoppm_path: /usr/bin/pdftoppm, pdfinfo_path: /usr/bin/pdfinfo}',
help_text=_(
default='''
{{
libreoffice_path: {},
pdftoppm_dpi: {},
pdftoppm_format: {},
pdftoppm_path: {},
pdfinfo_path: {},
pillow_format: {}
}}
'''.replace('\n', '').format(
DEFAULT_LIBREOFFICE_PATH, DEFAULT_PDFTOPPM_DPI,
DEFAULT_PDFTOPPM_FORMAT, DEFAULT_PDFTOPPM_PATH, DEFAULT_PDFINFO_PATH,
DEFAULT_PILLOW_FORMAT
), help_text=_(
'Configuration options for the graphics conversion backend.'
), global_name='CONVERTER_GRAPHICS_BACKEND_CONFIG',
)