I have a ghostscript command that converts a pdf into several PNG images (one for every page). The command arguments are as follows:
-dNOPAUSE -q -r300 -sPAPERSIZE=a4 -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -dUseTrimBox -sDEVICE=png16m -dBATCH -sOutputFile="C:\outputfile%d.png" -c \"30000000 setvmthreshold\" -f "C:\inputfile.pdf"
The pdf displays as regular A4 pages in Adobe Reader, but in the PNG images it becomes huge (2480 by 3507 pixels for instance).
if I change the resolution in the ghostscript command to -r110
the page size is correct but the image quality is very rastorized.
Is there another way to improve the quality of the image without affecting the image size?
Thanks
Got it! Added the following parameter to my GS command:
-dDownScaleFactor=3
From the GS documentation:
This causes the internal rendering to be scaled down by the given (small integer) factor before being output. For example, the following will produce a 200dpi output png from a 300dpi internal rendering:
gs -sDEVICE=png16m -r600 -dDownScaleFactor=3 -o tiger.png\ examples/tiger.png
I had a similar problem, where PDF conversion to PNG using ghostscript resulted in an image with much greater dimensions (including extra white space). I solved the issue by using
-dUseCropBox
... which sets the page size to the CropBox rather than the MediaBox
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With