Page 1 of 1

Page zero issue

Posted: 2016-07-26T07:34:08-07:00
by gustavopi
For programmers, the first item of a collection is usually the zero. But in my tests, when trying to create a thumb from a PDF document using Ghostscript, the first page got to be 1.

Code: Select all

$img = new Imagick($pdf.'[0]'); // WRONG  :( 
$img = new Imagick($pdf.'[1]'); // OK  :D 
(this example is from a question in stackoverflow)

The error is the same as happened to me we see around the web:

Code: Select all

Fatal error: Uncaught exception 'ImagickException' with message 
'PDFDelegateFailed `[ghostscript library] 
-dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 
"-sDEVICE=pam" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" 
-dUseCIEColor -dFirstPage=1 -dLastPage=1 
 -dname= must be followed by a valid token 
 @ error/pdf.c/InvokePDFDelegate/263'
  in /home/domain/public_html/pdfPreview.php:46 

  Stack trace: #0 /home/domain/public_html/pdfPreview.php(46): 
  #1 {main} thrown in 
  /home/domain/public_html/pdfPreview.php on line 46
The problem is not really about a name (-dname), is because no temporary file is generated to Imagick to load (though).

In my tests, this was happening with this version

Code: Select all

versionNumber: 1680
versionString: ImageMagick 6.9.0-0 Q16 x86_64 2016-05-05
But previous versions (don't know exacly which one) was not generating this error, so wrong codes (as my own) just stop working mysteriously. I found more guys like me, yeah, I was not the only one. I tuck some time to find that the error is not auto corrected anymore (why? You tell me).

I just think people of this cummunity should know about.

Re: Page zero issue

Posted: 2016-08-08T03:08:48-07:00
by broucaries
magick seems an API issue and maybe a security one. Could you get a glimpse

Re: Page zero issue

Posted: 2016-08-08T09:54:57-07:00
by magick
We did not write not so we maintain iMagick. We did try with the command-line and it appears to work properly:
  • convert rose: rose: wizard: logo: logo.pdf
    convert -verbose 'logo.pdf[0]' rose.png
Does it work as expected and return the first page? Now try [1]. Works? If not, you may need to post to the iMagick maintainers.