Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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";

1 Answers

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/

like image 164
SK-logic Avatar answered Sep 13 '25 06:09

SK-logic