My goal is to extract about 30 JPG or PNG images from a PDF using PHP. I’m using ImageMagick from PHP in a shared hosting. Imagick::readImage. (PECL imagick ). Imagick::readImage — Reads image from filename. Description. bool Imagick::readImage (string $filename). Example case: extract page 1 of a pdf file and save it as jpg image. $i = new Imagick(); $i->setResolution();.

Author: Fenrile Taukree
Country: Romania
Language: English (Spanish)
Genre: Politics
Published (Last): 17 October 2008
Pages: 77
PDF File Size: 16.68 Mb
ePub File Size: 13.36 Mb
ISBN: 460-4-44197-584-2
Downloads: 34090
Price: Free* [*Free Regsitration Required]
Uploader: Mikashura

Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? I’m using ImageMagick 6. I have tried several source PDFs having from 20 to 30 images each.

It always works fine for the first 10 images, but starting at index X and thereafter it always gets an exception. I tried the same test on another hosting account with PHP 7. It always gives an exception in the readImage command when index is geadimage 15 or higher depending on the source PDF.


Each page is essentially a big image.

How to Convert a PDF to JPEG using PHP – Arjun

The code above works for the first X pages, then fails with an exception. I’m trying to extract pages 0 to It seems that when you are reading a page that is far enough into the PDF file, it gets the exception. The first page is [0] and you are requesting page [15] which would be the 16 page. The Imagemagick developers have nothing to do with Rdadimage.

Does it work with a simple convert command line? Select all convert bound.


If it still fails try reading 5 pages at a time which will hopefully isolate the problem. ImageMagick examples mostly using php Imagick examples. They all fail on the readImage[X] command. Bear in mind this is running in PHP from a shared hosting account so I do not have a Command line environment to run a convert command.

To clarify, the entire script consists of only two lines. It is not running a loop and finally getting the exception on the 16th page.


Do you have access to PHP execso that you could run the command line and see if that fails?