Can't convert PDF into image, because of 'no images defined' error

88

11

I've the following PDF file: http://www.fmwconcepts.com/misc_tests/pdf_tests/test.pdf

But when I'm trying to convert it via:

$ convert test.pdf test.png

I've the following error:

convert: no images defined `test.png' @ error/convert.c/ConvertImageCommand/3187.

I've the following versions:

$ brew info libpng
libpng: stable 1.6.13 (bottled)

$ brew info libjpeg
jpeg: stable 8d (bottled)

$ brew info imagemagick
imagemagick: stable 6.8.9-7 (bottled), HEAD
http://www.imagemagick.org
/usr/local/Cellar/imagemagick/6.8.9-1 (1432 files, 22M) *
  Poured from bottle
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/imagemagick.rb
==> Dependencies
Build: xz ✔, pkg-config ✔
Required: libtool ✔
Recommended: jpeg ✔, libpng ✔, freetype ✔
Optional: fontconfig ✔, libtiff ✔, little-cms ✔, little-cms2 ✔, libwmf ✘, librsvg ✘, liblqr ✘, openexr ✘, ghostscript ✘, webp ✘

I've the following debug log:

$ convert test.pdf test.png -debug all
2014-10-01T15:29:39+01:00 0:00.000 0.000u 6.8.9 Configure convert[58320]: utility.c/ExpandFilenames/944/Configure
  Command line: convert {test.pdf} {test.png} {-debug} {all}
2014-10-01T15:29:39+01:00 0:00.000 0.000u 6.8.9 Configure convert[58320]: configure.c/GetConfigureOptions/679/Configure
  Searching for configure file: "/usr/local/Cellar/imagemagick/6.8.9-1/share/ImageMagick-6/coder.xml"
...
2014-10-01T15:29:39+01:00 0:00.020 0.010u 6.8.9 Module convert[58320]: module.c/OpenModule/1268/Module
  Searching for module "PNG" using filename "png.la"
2014-10-01T15:29:39+01:00 0:00.020 0.010u 6.8.9 Module convert[58320]: module.c/GetMagickModulePath/554/Module
  Searching for coder module file "png.la" ...
2014-10-01T15:29:39+01:00 0:00.020 0.010u 6.8.9 Module convert[58320]: module.c/OpenModule/1277/Module
  Opening module at path "/usr/local/Cellar/imagemagick/6.8.9-1/lib/ImageMagick//modules-Q16/coders/png.la"
2014-10-01T15:29:39+01:00 0:00.020 0.010u 6.8.9 Module convert[58320]: module.c/OpenModule/1304/Module
  Method "RegisterPNGImage" in module "PNG" at address 0x10a9fdb60
2014-10-01T15:29:39+01:00 0:00.020 0.010u 6.8.9 Module convert[58320]: module.c/OpenModule/1318/Module
  Method "UnregisterPNGImage" in module "PNG" at address 0x10aa0785d
2014-10-01T15:29:39+01:00 0:00.020 0.010u 6.8.9 Policy convert[58320]: policy.c/IsRightsAuthorized/574/Policy
  Domain: Path; rights=Read; pattern="test.png" ...
...
2014-10-01T15:29:39+01:00 0:00.020 0.010u 6.8.9 Configure convert[58320]: locale.c/LoadLocaleCache/1186/Configure
  Loading locale configure file "/usr/local/Cellar/imagemagick/6.8.9-1/share/ImageMagick-6/english.xml" ...
2014-10-01T15:29:39+01:00 0:00.020 0.020u 6.8.9 Exception convert[58320]: blob.c/OpenBlob/2657/Exception
  unable to open image `test.png': No such file or directory
2014-10-01T15:29:39+01:00 0:00.020 0.020u 6.8.9 Cache convert[58320]: cache.c/DestroyPixelCache/962/Cache
  destroy 
2014-10-01T15:29:39+01:00 0:00.020 0.020u 6.8.9 Policy convert[58320]: policy.c/IsRightsAuthorized/574/Policy
  Domain: Coder; rights=Read; pattern="PNG" ...
2014-10-01T15:29:39+01:00 0:00.030 0.020u 6.8.9 Coder convert[58320]: png.c/ReadPNGImage/4015/Coder
  Enter ReadPNGImage()
2014-10-01T15:29:39+01:00 0:00.030 0.020u 6.8.9 Policy convert[58320]: policy.c/IsRightsAuthorized/574/Policy
  Domain: Path; rights=Read; pattern="test.png" ...
2014-10-01T15:29:39+01:00 0:00.030 0.020u 6.8.9 Exception convert[58320]: blob.c/OpenBlob/2657/Exception
  unable to open image `test.png': No such file or directory
2014-10-01T15:29:39+01:00 0:00.030 0.020u 6.8.9 Exception convert[58320]: png.c/ReadPNGImage/4021/Exception
  unable to open file `test.png'

But doesn't showing anything obvious. And it seems that this debug log behaves completely different than without -debug, because the original error is not there. See the full log.

There is a similar issue at http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=22466, but I'm not quite get it what is the solution.

kenorb

Posted 2014-10-01T14:25:26.527

Reputation: 16 795

Answers

96

You are missing the optional Ghostscript dependency gs - which is not optional if you want to convert a PDF file.

If which gs doesn't resolve to the ghostscript binary (e.g. you have an alias with the same name), edit the path to Ghostscript in delegates.xml.

dlemstra

Posted 2014-10-01T14:25:26.527

Reputation: 1 403

2In my case I had Ghostscript installed but the gs command was hidden by a script I wrote for git status. Is there a way to feed ImageMagick the full path of the gs binary so that I don't have to remove my script (or alias)? – Sridhar Sarnobat – 2014-11-03T20:52:52.990

2You will need to edit the file delegates.xml and specify the alternative location. – dlemstra – 2014-11-03T21:06:08.233

debian/ubuntu: apt-get install ghostscript – Nadir – 2017-03-12T21:49:19.510

73

You can also try doing:

  1. brew uninstall ghostscript
  2. brew install ghostscript

That fixed it for me.

hotmeteor

Posted 2014-10-01T14:25:26.527

Reputation: 831

That did the trick! – line-o – 2015-08-28T11:09:23.293

-1

I had a similar problem. The fixes above didn't do anything for me, but it looks like ImageMagick was using html2ps internally.

So, the solution was to install that. I'm not on OS X, so for me the solution was:

apt install html2ps

Hopefully this will help somebody.

mlissner

Posted 2014-10-01T14:25:26.527

Reputation: 860

apt or apt-get? – kenorb – 2016-08-26T02:45:26.980

1apt if you have it. It's the replacement for apt-get. – mlissner – 2016-08-26T14:21:04.887

ImageMagick was using html2ps internally to convert from pdf to png here? – rogerdpack – 2017-03-03T01:44:29.853