Devin Dixon
Devin Dixon

Reputation: 12423

PHP Imagick PDF to JPEG Problem

I am having this error that comes up when I try to convert certain pdfs into JPEgs

The error message is:

[28-Mar-2011 13:24:02] PHP Fatal error:  Uncaught exception '
Stack trace:
#0 /home/bobdole/public_html/viewfile.php(41): Imagick->__con
#1 {main}
  thrown in /home/bobdole/public_html/viewfile.php on line 41

The code is:

$im = new imagick($file_location);//Line 41 is  here
    $im->setImageFormat( "jpg" );
    $pdf_pages=$im->getNumberImages();

Any idea what is causing the problem and how to fix it? It does not happen all the time, only with certain PDFs.

GhostScript is installed.

Upvotes: 1

Views: 1514

Answers (1)

Maarten Katoen
Maarten Katoen

Reputation: 53

I spent a lot of time playing around with all kinds of PDF-files and imagemagick. This might help others trying to get it all to work. I've found so many solutions here, wouldn't even know how to thank everyone, so here it goes ;)

After a lot of useless tinkering, I figured it wasn't imagemagick which didn't work, but Ghostsript. I had to get the latest version of Ghostscript (i had to build it from source, the packages weren't new enough). I tested it all with pretty much all the available PDF-versions. Updating ghostscript worked pretty well, but still some PDF's were not accepted.

In the end I checked out the logs and discovered that ghostscript fonts are key to the issue. I updated those. After this, it all went smooth. Actually have a site which converts any PDF, right now.

Upvotes: 1

Related Questions