Added the configuration option CONVERTER_GM_SETTINGS to pass GraphicsMagicks specific commands the the GM backend

This commit is contained in:
Roberto Rosario
2011-04-22 02:20:45 -04:00
parent e03cea8886
commit 6cdebb3910
4 changed files with 9 additions and 3 deletions

View File

@@ -1,6 +1,7 @@
import subprocess import subprocess
from converter.conf.settings import GM_PATH from converter.conf.settings import GM_PATH
from converter.conf.settings import GM_SETTINGS
from converter.api import QUALITY_DEFAULT, QUALITY_SETTINGS from converter.api import QUALITY_DEFAULT, QUALITY_SETTINGS
from converter.exceptions import ConvertError, UnknownFormat, IdentifyError from converter.exceptions import ConvertError, UnknownFormat, IdentifyError
@@ -25,6 +26,7 @@ def execute_convert(input_filepath, output_filepath, quality=QUALITY_DEFAULT, ar
command.append(unicode(GM_PATH)) command.append(unicode(GM_PATH))
command.append(u'convert') command.append(u'convert')
command.extend(unicode(QUALITY_SETTINGS[quality]).split()) command.extend(unicode(QUALITY_SETTINGS[quality]).split())
command.extend(unicode(GM_SETTINGS).split())
command.append(unicode(input_filepath)) command.append(unicode(input_filepath))
if arguments: if arguments:
command.extend(unicode(arguments).split()) command.extend(unicode(arguments).split())

View File

@@ -6,6 +6,7 @@ IM_CONVERT_PATH = getattr(settings, 'CONVERTER_IM_ONVERT_PATH', u'/usr/bin/conve
IM_IDENTIFY_PATH = getattr(settings, 'CONVERTER_IM_IDENTIFY_PATH', u'/usr/bin/identify') IM_IDENTIFY_PATH = getattr(settings, 'CONVERTER_IM_IDENTIFY_PATH', u'/usr/bin/identify')
UNPAPER_PATH = getattr(settings, 'CONVERTER_UNPAPER_PATH', u'/usr/bin/unpaper') UNPAPER_PATH = getattr(settings, 'CONVERTER_UNPAPER_PATH', u'/usr/bin/unpaper')
GM_PATH = getattr(settings, 'CONVERTER_GM_PATH', u'/usr/bin/gm') GM_PATH = getattr(settings, 'CONVERTER_GM_PATH', u'/usr/bin/gm')
GM_SETTINGS = getattr(settings, 'CONVERTER_GM_SETTINGS', u'')
GRAPHICS_BACKEND = getattr(settings, 'CONVERTER_GRAPHICS_BACKEND', u'converter.backends.imagemagick') GRAPHICS_BACKEND = getattr(settings, 'CONVERTER_GRAPHICS_BACKEND', u'converter.backends.imagemagick')
OCR_OPTIONS = getattr(settings, 'CONVERTER_OCR_OPTIONS', u'-colorspace Gray -depth 8 -resample 200x200') OCR_OPTIONS = getattr(settings, 'CONVERTER_OCR_OPTIONS', u'-colorspace Gray -depth 8 -resample 200x200')

View File

@@ -68,18 +68,19 @@ def check_settings(request):
'description': common_settings.setting_description}, 'description': common_settings.setting_description},
# Converter # Converter
{'name': 'CONVERTER_IM_CONVERT_PATH',
'value': converter_settings.IM_CONVERT_PATH, 'exists': True,
'description': converter_settings.setting_description},
{'name': 'CONVERTER_UNPAPER_PATH', {'name': 'CONVERTER_UNPAPER_PATH',
'value': converter_settings.UNPAPER_PATH, 'exists': True, 'value': converter_settings.UNPAPER_PATH, 'exists': True,
'description': converter_settings.setting_description}, 'description': converter_settings.setting_description},
{'name': 'CONVERTER_IM_CONVERT_PATH',
'value': converter_settings.IM_CONVERT_PATH, 'exists': True,
'description': converter_settings.setting_description},
{'name': 'CONVERTER_IM_IDENTIFY_PATH', {'name': 'CONVERTER_IM_IDENTIFY_PATH',
'value': converter_settings.IM_IDENTIFY_PATH, 'exists': True, 'value': converter_settings.IM_IDENTIFY_PATH, 'exists': True,
'description': converter_settings.setting_description}, 'description': converter_settings.setting_description},
{'name': 'CONVERTER_GM_PATH', {'name': 'CONVERTER_GM_PATH',
'value': converter_settings.GM_PATH, 'exists': True, 'value': converter_settings.GM_PATH, 'exists': True,
'description': converter_settings.setting_description}, 'description': converter_settings.setting_description},
{'name': 'CONVERTER_GM_SETTINGS', 'value': converter_settings.GM_SETTINGS},
{'name': 'CONVERTER_GRAPHICS_BACKEND', {'name': 'CONVERTER_GRAPHICS_BACKEND',
'value': converter_settings.GRAPHICS_BACKEND, 'value': converter_settings.GRAPHICS_BACKEND,
'description': converter_settings.setting_description}, 'description': converter_settings.setting_description},

View File

@@ -221,6 +221,8 @@ TEMPLATE_CONTEXT_PROCESSORS = (
#CONVERTER_IM_IDENTIFY_PATH = u'/usr/bin/identify' #CONVERTER_IM_IDENTIFY_PATH = u'/usr/bin/identify'
#CONVERTER_UNPAPER_PATH = u'/usr/bin/unpaper' #CONVERTER_UNPAPER_PATH = u'/usr/bin/unpaper'
#CONVERTER_GRAPHICS_BACKEND = u'converter.backends.imagemagick' #CONVERTER_GRAPHICS_BACKEND = u'converter.backends.imagemagick'
#CONVERTER_GM_PATH = u'/usr/bin/gm'
#CONVERTER_GM_SETTINGS = u''
# OCR # OCR
#OCR_TESSERACT_PATH = u'/usr/bin/tesseract' #OCR_TESSERACT_PATH = u'/usr/bin/tesseract'