diff --git a/apps/converter/backends/python/base.py b/apps/converter/backends/python/base.py index a7e404bd46..dddfa71e7e 100644 --- a/apps/converter/backends/python/base.py +++ b/apps/converter/backends/python/base.py @@ -25,7 +25,7 @@ class ConverterClass(ConverterBase): def get_page_count(self, input_filepath): page_count = 1 - mimetype, encoding = get_mimetype(open(input_filepath, 'rb'), input_filepath) + mimetype, encoding = get_mimetype(open(input_filepath, 'rb'), input_filepath, mimetype_only=True) if mimetype == 'application/pdf': # If file is a PDF open it with slate to determine the page # count @@ -48,9 +48,12 @@ class ConverterClass(ConverterBase): return page_count - def convert_file(self, input_filepath, output_filepath, transformations=None, page=DEFAULT_PAGE_NUMBER, file_format=DEFAULT_FILE_FORMAT): + def convert_file(self, input_filepath, output_filepath, transformations=None, page=DEFAULT_PAGE_NUMBER, file_format=DEFAULT_FILE_FORMAT, **kwargs): tmpfile = None - mimetype, encoding = get_mimetype(open(input_filepath, 'rb'), input_filepath) + mimetype = kwargs.get('mimetype', None) + if not mimetype: + mimetype, encoding = get_mimetype(open(input_filepath, 'rb'), input_filepath, mimetype_only=True) + if mimetype == 'application/pdf' and USE_GHOSTSCRIPT: # If file is a PDF open it with ghostscript and convert it to # TIFF