How to improve the quality of JPEG images created from PDF files using Ghostscript?

I use this code to create JPEG images from a PDF file:

String cmd = @"./lib/gswin32c";
String args = "-dNOPAUSE -sDEVICE=jpeg -dJPEGQ=100 -dBATCH -dSAFER -sOutputFile=" + fileName + "-%03d.jpg " + fileName + ".pdf";
Process proc = new Process();
proc.StartInfo.FileName = cmd;
proc.StartInfo.Arguments = args;
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.UseShellExecute = false;
proc.Start();

I work very well, but the quality is really poor. It seems to be blurry. Any tips on improving quality?

EDIT

Now I use the following arguments and it works as expected:

String args = "-dNOPAUSE -sDEVICE=pngalpha -r300 -dBATCH -dSAFER -sOutputFile=" + fileName + "-%03d" + FILEEXTENSION + " " + fileName + ".pdf";
+3
source share
3 answers

Jpeg? For documents? Create gifs or png if you can. JPEGs are not suitable for anything other than photographs, even at "maximum" quality.

http://lbrandy.com/blog/2008/10/my-first-and-last-webcomic/

+3
source

, , , , -dCOLORSCREEN -dDOINTERPOLATE. !:)

+1

I just struggled with pdf quality in jpeg and changed on the recommendation of dk-logic to gif.

This may help someone, because I now have almost perfect quality with the following command

gs -sDEVICE=png16m -r600 -dDownScaleFactor=3 -o outfile.png inFile.pdf

According to the docs

-dDownScaleFactor = integer

This leads to a decrease in internal rendering (small integer) coefficient before the output. For example, the above will give 200ppi output png from internal rendering of 600 dpi:

0
source

Source: https://habr.com/ru/post/1794011/


All Articles