2

When I am executing the below command (to create thumbnail of a pdf file)

convert -density 300 'image.pdf' -colorspace RGB -resize '100x100^' -gravity north -extent 100x100 'image_thumbnail.jpg

I am getting the below error

convert: FailedToExecuteCommand `'gs' -sstdout=%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 '-sDEVICE=pngalpha' -dTextAlphaBits=4 -dGraphicsAlphaBits=4 '-r72x72' -dFirstPage=1 -dLastPage=1 '-sOutputFile=/tmp/magick-2243905865hWInyt6%d' '-f/tmp/magick-22439X8ArwDDJggvw' '-f/tmp/magick-22439Omw2cAWv3jxW'' (-1) @ error/delegate.c/ExternalDelegateCommand/478.

Prashant
  • 593
  • 4
  • 6
  • Is ghostscript installed? – emcconville Nov 30 '18 at 11:37
  • If Ghostscript is installed, then see https://stackoverflow.com/questions/52861946/imagemagick-not-authorized-to-convert-pdf-to-an-image/52863413#52863413 regarding the security policy for reading PDF files. – fmw42 Nov 30 '18 at 18:57
  • Note that you should be using -colorspace sRGB before reading the pdf. `convert -colorspace sRGB -density 300 'image.pdf' -resize '100x100^' -gravity north -extent 100x100 'image_thumbnail.jpg`. Use colorspace RGB only if you want linear RGB rather than non-linear sRGB. Or if you are using a very ancient version of ImageMagick where the two were reversed. – fmw42 Nov 30 '18 at 18:59

1 Answers1

3

Hi Prashant.

I had such an issue using node-pdf-image package. I had been investigating it for several days before I found the solution. I tried to update the versions of ImageMagick and GhostScript, but it didn't help.

The only workaround I found was the next one: use GraphicsMagick and invoke the convert prefixed with gm - like gm convert [options].

But of course, this solution was acceptable for my stuff, and it depends on the task.

styleofspur
  • 123
  • 2
  • 11