Page zero issue

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
gustavopi
Posts: 10
Joined: 2015-05-19T11:23:43-07:00
Authentication code: 6789

Page zero issue

Post by gustavopi » 2016-07-26T07:34:08-07:00

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] 
-q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT 
-dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 
"-sDEVICE=pam" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" 
-dUseCIEColor -dFirstPage=1 -dLastPage=1 
"-sOutputFile=/tmp/magick-1514TynhowIwvsS8%d" 
"-f/tmp/magick-1514ToUFRp0QWKlG" 
"-f/tmp/magick-1514zEMWRNGv55Od"':
 -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): 
  Imagick->__construct('./assets/whatsn...') 
  #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.

broucaries
Posts: 467
Joined: 2008-12-21T11:51:10-07:00

Re: Page zero issue

Post by broucaries » 2016-08-08T03:08:48-07:00

magick seems an API issue and maybe a security one. Could you get a glimpse

User avatar
magick
Site Admin
Posts: 10984
Joined: 2003-05-31T11:32:55-07:00

Re: Page zero issue

Post by magick » 2016-08-08T09:54:57-07:00

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.

Post Reply