简体   繁体   English

如何使用Ghostscript提高从PDF生成的JPEG图像的质量?

[英]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: 我使用此代码从PDF文件生成JPEG图像:

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? JPEG? For documents ? 对于文件 Generate gifs or pngs, if you can. 如果可以的话,生成GIF或png。 JPEGs are unsuitable for anything else than photos, even at a "maximum" quality setting. 即使在“最高”质量设置下,JPEG也不适用于除照片之外的任何其他内容。

http://lbrandy.com/blog/2008/10/my-first-and-last-webcomic/ 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 . 我快速查看了文档 ,似乎有一些影响图像质量的选项,如-dCOLORSCREEN-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. 我一直在努力将pdf的质量转化为jpeg,并且已经将dk-logic的建议改为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 -dDownScaleFactor =整数

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: 例如,以上将从600dpi内部渲染产生200dpi输出png:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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