From f682a3d305bcdbfc26ef8562dc6965edd6f08ca4 Mon Sep 17 00:00:00 2001 From: mayurchoksi Date: Thu, 27 Dec 2018 16:45:00 -0500 Subject: [PATCH] Resolved "No decode delegate for this image format" when converting the full PDF (all pages) to png Exception encountered when running - Alpine in Docker container. - Node 10 - Imagemagick - pdf-image 2.0.0 --- index.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index 4fa6231..927beab 100644 --- a/index.js +++ b/index.js @@ -85,12 +85,22 @@ PDFImage.prototype = { var pdfFilePath = this.pdfFilePath; var outputImagePath = this.getOutputImagePathForPage(pageNumber); var convertOptionsString = this.constructConvertOptions(); - return util.format( - "%s %s\"%s[%d]\" \"%s\"", - this.useGM ? "gm convert" : "convert", - convertOptionsString ? convertOptionsString + " " : "", - pdfFilePath, pageNumber, outputImagePath - ); + + if(util.types.isNumberObject(pageNumber)) { + return util.format( + "%s %s\"%s[%d]\" \"%s\"", + this.useGM ? "gm convert" : "convert", + convertOptionsString ? convertOptionsString + " " : "", + pdfFilePath, pageNumber, outputImagePath + ); + } else { + return util.format( + "%s %s\"%s\" \"%s\"", + this.useGM ? "gm convert" : "convert", + convertOptionsString ? convertOptionsString + " " : "", + pdfFilePath, outputImagePath + ); + } }, constructCombineCommandForFile: function (imagePaths) { return util.format(