node-pdf-image icon indicating copy to clipboard operation
node-pdf-image copied to clipboard

How to convert PDF document to PNG image without compression?

Open TylerCreator opened this issue 6 years ago • 4 comments

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

TylerCreator avatar Jun 03 '18 07:06 TylerCreator

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

roest01 avatar Jun 03 '18 16:06 roest01

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)+'%' } });

TylerCreator avatar Jun 04 '18 11:06 TylerCreator

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

dkonsoftware avatar Jan 04 '19 21:01 dkonsoftware

@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.

rainabba avatar Feb 07 '19 14:02 rainabba