0

I am trying to convert pdf to images in node.js app. For that I am using pdf-image npm module.

I googled it and installed pdf-image npm module and graphicsmagick using apt-get install graphicsmagick in linux os.

let pdfImage = new PDFImage("./file.pdf",{graphicsMagick: true,convertOptions: {
            "-resize": "2000x2000",
            "-quality": "75"
          }}); 
        pdfImage.convertFile().then((imagePaths)=>{
            console.log(imagePaths)
            cb(null,imagePaths)
        },(err)=>{
            cb(err)
        });

In my local system its working fine and perfect. But when I deployed this to my AWS ec2 instance and installed all required libraries but its throwing error

gm convert: Coder did not return an image (this is a bug, please report it!)

I am doing the same as local in ec2 instance but its not working.

halfer
  • 19,824
  • 17
  • 99
  • 186
Saurabh Sharma
  • 804
  • 6
  • 16
  • 42

2 Answers2

0

sudo apt-get install ImageMagick Ghostscript poppler-utils

In

/etc/ImageMagick-6/policy.xml (or /etc/ImageMagick/policy.xml)

find the following line

and change it to allow reading and writing by the PDF coder in ImageMagick:

if use this sudo service php7.2-fpm restart require to restart

SAVe
  • 814
  • 6
  • 22
0

Solved similar problem in Rails framework by changing cli to imagemagick (was graphicsmagick that was the cause of the error)

MiniMagick.configure do |config|
  config.cli = :imagemagick # or :graphicsmagick or :imagemagick7
end

https://www.rubydoc.info/github/minimagick/minimagick