[Solved]Cannot convert from PDF to TIFF

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
TennSeven
Posts: 6
Joined: 2012-01-30T13:33:53-07:00
Authentication code: 8675308

[Solved]Cannot convert from PDF to TIFF

Post by TennSeven »

Hi all,

Every time I try to convert a file from pdf to tiff I get the following error:

Code: Select all

GPL Ghostscript 9.04: Unrecoverable error, exit code 1
convert: Postscript delegate failed `test.pdf': No such file or directory @ error/pdf.c/ReadPDFImage/667.
convert: missing an image filename `test.tif' @ error/convert.c/ConvertImageCommand/3016.
I am running 64-bit Ubuntu, and I had originally installed ImageMagick using Ubuntu's package manager, Synaptic. When I ran into this error, I uninstalled the ImageMagick package, installed the tiff-3.9.5 delegate from ftp://ftp.imagemagick.org/pub/ImageMagick/delegates/, and re-installed the newest version of ImageMagick from source (using instructions on http://www.imagemagick.org/script/insta ... e.php#unix). I have verified both that I have the latest version of GhostScript installed, and that convert (both the original install and the new install) has "tiff" in the delegates list. I believe the original convert also listed "pdf" in the delegates list (I am not positive), but it does not appear there in the new install.

The command lines I have tried are:

Code: Select all

convert test.pdf test.tif
and

Code: Select all

convert test.pdf tiff:test.tif
Would someone please help me figure out how to fix this error? I am in a time crunch and really need to finish converting a directory full of PDFs.


Thank you!

-TennSeven
Last edited by TennSeven on 2012-02-18T16:56:21-07:00, edited 1 time in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Cannot convert from PDF to TIFF

Post by fmw42 »

I think you will need to post a link to your test.pdf so that others can test with it.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Cannot convert from PDF to TIFF

Post by fmw42 »

Does

convert -list configure

list gs in the line starting with DELEGATES. If not then IM is not seeing Ghostscript.
TennSeven
Posts: 6
Joined: 2012-01-30T13:33:53-07:00
Authentication code: 8675308

Re: Cannot convert from PDF to TIFF

Post by TennSeven »

I have tried with a number of pdf files, but an easy one to get to is right here:

http://www.education.gov.yk.ca/pdf/pdf-test.pdf

Also, I have verified that I can convert a TIFF to a GIF, but not a PDF to a GIF, so it is definitely having problems reading PDF files. I have tried the following ghostscript command (using the downloaded PDF from the link above):

Code: Select all

gs -sDEVICE=tiffg4 -sOutputFile=test.tif pdf-test.pdf

And that appears to work.

-TennSeven
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Cannot convert from PDF to TIFF

Post by fmw42 »

This command works for me. Note your pdf has transparency so it has to be flattened against white.

convert pdf-test.pdf -background white -flatten pdf-test.tiff


Does

convert -list configure

list gs in the line starting with DELEGATES. If not then IM is not seeing Ghostscript.


If you have gs installed AND IM sees it, then note you have two ps devices that can be used for pdf. One pngalpha will allow transparency but only one page. The other pnmraw (I believe) allows multiple pages, but no transparency. You will need to check your delegates.xml file to see what device is being use.
TennSeven
Posts: 6
Joined: 2012-01-30T13:33:53-07:00
Authentication code: 8675308

Re: Cannot convert from PDF to TIFF

Post by TennSeven »

"convert -list configure" does not list "gs" in DELEGATES. It only lists "mpeg tiff x11".

However, when I installed ImageMagick from source, the "./configure" command did provide the following output (scroll down to the 4th to last line):

Code: Select all

                  Option                        Value
-------------------------------------------------------------------------------
Shared libraries  --enable-shared=yes		yes
Static libraries  --enable-static=yes		yes
Module support    --with-modules=no		no
GNU ld            --with-gnu-ld=yes		yes
Quantum depth     --with-quantum-depth=16	16
High Dynamic Range Imagery
                  --enable-hdri=no		no

Delegate Configuration:
BZLIB             --with-bzlib=yes		no
Autotrace         --with-autotrace=no		no
Dejavu fonts      --with-dejavu-font-dir=default	none
DJVU              --with-djvu=yes		no
DPS               --with-dps=yes		no
FFTW              --with-fftw=yes		no
FlashPIX          --with-fpx=yes		no
FontConfig        --with-fontconfig=yes		no
FreeType          --with-freetype=yes		no
GhostPCL          None				pcl6 (unknown)
GhostXPS          None				gxps (unknown)
Ghostscript       None				gs (9.04)
Ghostscript fonts --with-gs-font-dir=default	/usr/share/fonts/type1/gsfonts/
Ghostscript lib   --with-gslib=no		no
...[truncated]

Which seems to suggest that it knew I had ghostscript 9.04 when I installed it. How do I get IM to see Ghostscript?


-TennSeven
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Cannot convert from PDF to TIFF

Post by fmw42 »

Unless it shows in your list of DELEGATES, then IM did not find or link it or it found it but GS was not properly installed and so could not use it.

Did you install form source or binary? If from source, what does your configure command look like. Does it have --with gslib and point to the gs fonts. See http://www.imagemagick.org/script/advan ... #configure

Here is mine:

./configure CPPFLAGS='-I/opt/local/include' LDFLAGS='-L/opt/local/lib' \
--enable-delegate-build --enable-shared --disable-static \
--with-modules --with-quantum-depth=16 --with-gslib --without-wmf \
--disable-silent-rules --disable-dependency-tracking --without-pango \
--with-gs-font-dir=/opt/local/share/ghostscript/fonts/ --with-lqr
TennSeven
Posts: 6
Joined: 2012-01-30T13:33:53-07:00
Authentication code: 8675308

Re: Cannot convert from PDF to TIFF

Post by TennSeven »

Thank you for the command line information. I tried doing what you said, but the configure command outputted this line:

Code: Select all

Ghostscript lib   --with-gslib=yes		no
Meaning that, even though I specified --with-gslib, for some reason it did not find it, or still did not add it as a delegate. I am not sure where to go from here. As far as I can tell, I cannot uninstall and then re-install ghostscript, because there are so many packages dependent on it, including ubuntu-desktop. I think there are some ghostscript dummy packages that allow you to accomplish this, but I will have to look into it.

Any other ideas? Also, is there any way to add a delegate, like ghostscript, after ImageMagick is already installed, or do you have to re-install every time you want to add or remove delegates?

Thanks again.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Cannot convert from PDF to TIFF

Post by fmw42 »

Sorry, what I mean is type on your terminal:

convert -list configure

Look at the line staring with DELEGATES. Here is mine:


DELEGATES bzlib fftw fontconfig freetype gs jpeg jng jp2 lcms2 lqr openexr png rsvg tiff x11 xml zlib


If gs is not there then IM did not find it or could not link to it probably because it was not properly installed.

Reinstall Ghostscript and be sure you get no error messages. Check the config.log file if necessary.

Then reinstall IM using

./configure ... --with-gslib ... --with-gs-font-dir=path_to_gs_fonts ... (along with all your other config options)

Check the terminal to see if GS was installed with IM and then do make and make install.

That is the best I can offer.
TennSeven
Posts: 6
Joined: 2012-01-30T13:33:53-07:00
Authentication code: 8675308

Re: Cannot convert from PDF to TIFF

Post by TennSeven »

Thanks again for the information. Your instructions were clear in the previous post, it is just that, even though ghostscript is installed (and properly, as far as I can tell), ImageMagick is not finding it when I make it from the source. I specified where the fonts are as per your instructions and ImageMagick seems to find those, but even setting the "--with-gslib" flag, ImageMagick acknowledges in the output generated by the "configure" command that I set the flag, but still indicates that it does not see the ghostscript libraries, and therefore my DELEGATES list does not contain "gs" once the install is through.

For now, I am using ghostscript directly to make the conversions, and after I will revisit this issue and try to re-install ghostscript to see if ImageMagick can find it. I am wondering if I can explicitly tell ImageMagick where to look for the ghostscript libraries via the configure options, just like you can explicitly point it to the ghostscript fonts.

At any rate, I appreciate the help, and I will post in this thread again if I find a way to reinstall ghostscript and get IM to see it.

EDIT:

Also, looking in the "config.log" directory for IM, I find these entries:

Code: Select all

configure:29092: checking for Ghostscript
configure:29094: result:
configure:29099: checking ghostscript/iapi.h usability
configure:29099: gcc -std=gnu99 -std=gnu99 -c  -fopenmp -g -O2 -Wall -pthread  -I/home/ellisju/Downloads/ImageMagick-6.7.5-0/magick -I/home/ellisju/Downloads/ImageMagick-6.7.5-0/wand  conftest.c >&5
conftest.c:272:30: fatal error: ghostscript/iapi.h: No such file or directory
compilation terminated.
Again, I think IM simply does not know where to locate my gs installation.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Cannot convert from PDF to TIFF

Post by fmw42 »

fatal error: ghostscript/iapi.h: No such file or directory
Looks like something is not installed. I believe that I had that problem a long time ago and do not recall where I found the iapi.h file.

Perhaps it is from a GS dependency.

Have you tried a different version of Ghostscript?

Search Google for iapi.h and see if someone reports that same problem and solution. Or search the IM forum and see if there is any clues.


See viewtopic.php?f=2&t=10937&p=34831&hilit=iapi.h#p34831

IM has moved the location of some files. If you still have them in the old locations that may cause a conflict. You can search your computer for iapi.h and see how many occurrences and where they reside. Then delete the ones not needed for the current releases.

I am not sure this is the issue, since that post is very very old. But there was a relatively recent change of the location of some files.
TennSeven
Posts: 6
Joined: 2012-01-30T13:33:53-07:00
Authentication code: 8675308

Re: Cannot convert from PDF to TIFF

Post by TennSeven »

Hi all,

I just wanted to post here that I revisited this issue and found the solution. Even though I had ghostscript installed, I did not have the "libgs-dev" package installed, which contains the ghostscript development libraries that Imagemagick actually needs. I installed libgs-dev and then uninstalled and re-installed Imagemagick, and now gs shows up as a delegate, and everything else works as it is supposed to.

Again, thank you everyone for your help!

-TennSeven
Post Reply