mooz / node-pdf-image

Provides an interface to convert PDF's pages to png files in Node.js by using ImageMagick
MIT License
237 stars 87 forks source link

how to edit image's property? such as: quality, width, height #22

Open yellowChao opened 8 years ago

alexcroox commented 8 years ago

https://github.com/mooz/node-pdf-image/pull/21/commits/50ee40945cc25a7e47482d3030d5b65c1e52ac93

alexcroox commented 8 years ago

The quality flag doesn't seem to do much for me, the image contained in my test PDF is of very high quality but it comes out heavily pixilated even at medium sizes using the linked options.

haydenbleasel commented 8 years ago

We should be using the -size tag to specify an input size but it's ignoring it.

codecounselor commented 8 years ago

Many ImageMagick options must come after the filename, see this example http://stackoverflow.com/a/6605085 But the code currently lists them all before the source file.
(These are known as Image Operators )

Update: It seems that this is actually working despite the ordering

zjr commented 7 years ago

The PDFImage 'class' takes a second options parameter. You can use it like this:

const pdfImageOpts = {
  outputDirectory: path.join(__dirname, './wmReports/images'),
  convertExtension: 'jpg',
  convertOptions: {
    '-colorspace': 'RGB',
    '-interlace': 'none',
    '-density': '300',
    '-quality': '100'
  }
};

const pdfImage = new PDFImage(file, pdfImageOpts);

pdfImage.convertPageā€¦ // etc. etc..
tchantzakos commented 5 years ago

The quality flag doesn't seem to do much for me, the image contained in my test PDF is of very high quality but it comes out heavily pixilated even at medium sizes using the linked options.

almost 3 years later but did you find any solution to avoid the pixilized output image?

blqke commented 5 years ago

The quality flag doesn't seem to do much for me, the image contained in my test PDF is of very high quality but it comes out heavily pixilated even at medium sizes using the linked options.

almost 3 years later but did you find any solution to avoid the pixilized output image?

Had the same problem, the -density parameter resolved my case