1

我目前正在尝试使用 Ghostscript(或更具体地说是GhostscriptSharp,C# 包装器版本)生成 PDF 的缩略图,并且遇到了一些正在输出的图像质量问题。

使用以下方法:

GeneratePageThumbs(string inputPath, string outputPath, int firstPage, int lastPage, int width, int height)

并将宽度和高度更改为较小的数字,这将生成一个与我正在寻找的大小大致相同的缩略图,例如高度为 12 和宽度为 8 将生成一组大小为 102 x 88 像素的缩略图。

理想情况下 - 我正在尝试生成大小为 100 x 80 的缩略图,当呈现为 HTML(在图像标签中)时看起来相当不错,以便读者可以从缩略图中了解他们正在查看的内容(因为它目前完全不可读)

这些是当前设置(来自 C# 包装器):

private static readonly string[] ARGS = new string[] {
     // Keep gs from writing information to standard output
     "-q",                     
     "-dQUIET",

     "-dPARANOIDSAFER",         // Run this command in safe mode
     "-dBATCH",                 // Keep gs from going into interactive mode
     "-dNOPAUSE",               // Do not prompt and pause for each page
     "-dNOPROMPT",              // Disable prompts for user interaction           
     "-dMaxBitmap=500000000",   // Set high for better performance
     "-dNumRenderingThreads=4", // Multi-core, come-on!

     // Configure the output anti-aliasing, resolution, etc
     "-dAlignToPixels=0",
     "-dGridFitTT=0",
     "-dTextAlphaBits=4",
     "-dGraphicsAlphaBits=4"
};

但是 - 我不太熟悉 Ghostsharp 及其在尺寸和质量之间取得平衡的设置。我不反对创建更大的图像并为缩略图缩放它们,尽管如果可能的话,我更愿意让缩略图正常工作。

4

1 回答 1

3

如果没有看到原始文档,我无法确定,但在我看来,102x88 像素似乎不太可能足以创建可读的文本。

对于这个尺寸,TextAlphaBits 可能太大了,你只会得到一个模糊。尝试根本不设置 TextAlphaBits。NumRenderingThreads 不会对这么小的页面做任何有用的事情(尽管它也不会造成任何伤害)。

于 2012-05-15T07:13:32.023 回答