Paperless: convert: no images defined

Created on 12 Feb 2016  路  3Comments  路  Source: the-paperless-project/paperless

On Mac, OS X Yosemite 10.10.3

Not sure if relevant, I installed imagemagick via brew and so likewise changed the path to the corresponding CONVERT_BINARY in settings.py to "/usr/local/bin/convert"... even after clearing cache, this is an example of the output from the document_consumer script:

Consuming /Users/miles/Admin/Scanned/IMG_0001.pdf
convert: no images defined `/tmp/paperless/2623688.png' @ error/convert.c/ConvertImageCommand/3241.
Traceback (most recent call last):
  File "./manage.py", line 18, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/miles/Library/Python/3.5/lib/python/site-packages/django/core/management/__init__.py", line 350, in execute_from_command_line
    utility.execute()
  File "/Users/miles/Library/Python/3.5/lib/python/site-packages/django/core/management/__init__.py", line 342, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/miles/Library/Python/3.5/lib/python/site-packages/django/core/management/base.py", line 348, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/Users/miles/Library/Python/3.5/lib/python/site-packages/django/core/management/base.py", line 399, in execute
    output = self.handle(*args, **options)
  File "/Users/miles/Admin/paperless/src/documents/management/commands/document_consumer.py", line 68, in handle
    self.loop()
  File "/Users/miles/Admin/paperless/src/documents/management/commands/document_consumer.py", line 98, in loop
    text = self._get_ocr(pngs)
  File "/Users/miles/Admin/paperless/src/documents/management/commands/document_consumer.py", line 161, in _get_ocr
    guessed_language = langdetect.detect(raw_text)
  File "/Users/miles/Library/Python/3.5/lib/python/site-packages/langdetect/detector_factory.py", line 130, in detect
    return detector.detect()
  File "/Users/miles/Library/Python/3.5/lib/python/site-packages/langdetect/detector.py", line 135, in detect
    probabilities = self.get_probabilities()
  File "/Users/miles/Library/Python/3.5/lib/python/site-packages/langdetect/detector.py", line 142, in get_probabilities
    self._detect_block()
  File "/Users/miles/Library/Python/3.5/lib/python/site-packages/langdetect/detector.py", line 149, in _detect_block
    raise LangDetectException(ErrorCode.CantDetectError, 'No features in text.')
langdetect.lang_detect_exception.LangDetectException: No features in text.

A cursory glance at the /tmp/paperless/ directory also confirms that there are no files there. Does that directory need particular permissions for the PNGs to be created?

Most helpful comment

Hey Daniel, I think I've figured it out.

When using brew to install ImageMagick, it doesn't resolve the dependency ghostscript which provides the binary gs that is necessary for PDF conversion.

Here's the thread I found:

Can't Convert PDF Into Image - Super User

The issue is fixed by running:

brew install ghostscript in addition to brew install imagemagick

All 3 comments

The consumption directory needs to be readable and writeable by the paperless user, and have the disk space to write the files (usually less than a few MB).

Since convert is only invoked in one place, I have to assume that there's something amiss with the arguments being passed to it. In this case, there's only two variables: doc (the path to the original PDF) and png the path to the target PNG. If convert is complaining that no images defined /path/to/image.png that makes me think that in your context, doc is in fact "" and convert is treating the png image as a first argument rather than a second one.

Except that the debug info you posted here sounds like there is in fact a value for doc in your case, so I'm at a loss. Maybe try editing the consumer and adding a print() just before the Popen() line to see just what's about to get executed?

Hey Daniel, I think I've figured it out.

When using brew to install ImageMagick, it doesn't resolve the dependency ghostscript which provides the binary gs that is necessary for PDF conversion.

Here's the thread I found:

Can't Convert PDF Into Image - Super User

The issue is fixed by running:

brew install ghostscript in addition to brew install imagemagick

@blackwood Thank you! I had the same issue with MiniMagick

Was this page helpful?
0 / 5 - 0 ratings

Related issues

phryneas picture phryneas  路  7Comments

eonist picture eonist  路  7Comments

ddddavidmartin picture ddddavidmartin  路  8Comments

chezmoa picture chezmoa  路  7Comments

bee-san picture bee-san  路  3Comments