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 convert PDF document to PNG image without compression? #40

Open TylerCreator opened 6 years ago

TylerCreator commented 6 years ago

Setting quality option doesn't work for me. What should i put to convertOptions: { "-quality": "???" "-???" : "???" }?

roest01 commented 6 years ago

it work technically with value "100".

convertOptions: {
    "-quality": "100"
}

The quality setting has no effect on the appearance or signature of PNG and MNG images, since the compression is always lossless.

Not all combinations of compression level, strategy, and PNG filter type can be obtained using the -quality option. For more precise control, you can use the PNG:compression-level=N, PNG:compression-strategy=N, and PNG:compression-filter=N defines, respectively, instead. See -define. Values from the defines take precedence over values from the -quality option.

for more information please read command-line-options.php#quality

TylerCreator commented 6 years ago

After I execute "brew install graphicsmagick" it worked for me const BLUR_RATIO = 4; let pdfImage = new PDFImage(pdfName, { graphicsMagick: true, convertOptions: { '-density': ''+72*BLUR_RATIO, '-resize': Math.round(100/BLUR_RATIO)+'%' } });

dkonsoftware commented 5 years ago

Try higher density, for eg. : convertOptions: { "-density": "300", "-quality": "100" }

rainabba commented 5 years ago

@TylerCreator Looking at your code, I wondered if your density value was even valid given that code (which does work) and I wanted to throw this out there as a more readable and safer approach: (72 * BLUR_RATIO).toString()

Did you get things working as you wanted? I'm working along the same path right now, though no issue yet. I'm just doing my research first.