简体   繁体   中英

How to improve the quality of JPEG images that are generated from PDFs using Ghostscript?

I use this code to generate 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 works really fine, but the quality is really bad. It seems to be blurred. Any hints how to improve the quality?

EDIT

Now I'm using the following arguments and it is working as expected:

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

JPEG? For documents ? Generate gifs or pngs, if you can. JPEGs are unsuitable for anything else than photos, even at a "maximum" quality setting.

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

I've quickly look through the document and it seems there are some options to affect image quality like -dCOLORSCREEN and -dDOINTERPOLATE . Try them! :)

I have just been struggling with the quality of a pdf to jpeg and have changed on the advice of dk-logic to gif.

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

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

According the the docs

-dDownScaleFactor =integer

This causes the internal rendering to be scaled down by the given (small integer) factor before being output. For example, the above will produce a 200dpi output png from a 600dpi internal rendering:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM