0

I'm trying to convert PDF images to jpeg thumbnails. Following is a sample code with GraphicMagick.

const gm = require("gm");
const imageMagick = gm.subClass({ imageMagick: true });

image = imageMagick(fileBuffer).selectFrame(0);

image.size(function onSizeComplete(err, size) {

   image.quality(40).resize('', 200)
     .toBuffer("jpeg", async function (error, buffer) {
        if (error) {
            logger.info("error buffer: " + error);
        } else {
            //upload the image
        }
      });
            
});

This code is working fine for PDF with more than 1 page. When I'm trying to convert PDF with a single page the thumbnail image is just black. I'm not able to figure out the issue.

Edit: I tried changing some code. If I remove the .resize() call it's working fine

Abhishek
  • 23
  • 4

0 Answers0