我目前正嘗試使用Ghostscript(或更具體地說是GhostscriptSharp,C#包裝版本)生成PDF縮略圖,並遇到了一些與輸出圖像質量有關的問題。使用Ghostscript生成高質量(或可讀)縮略圖
使用下面的方法:
GeneratePageThumbs(string inputPath, string outputPath, int firstPage, int lastPage, int width, int height)
和改變的寬度和高度,以更小的數字,將產生的縮略圖大致,我尋找的尺寸,例如爲8 12的高度和寬度會生成一組尺寸爲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及其設置罷工規模的平衡和質量。我不會反對創建更大的圖像並縮放縮略圖,儘管如果可能的話我寧願讓縮略圖工作。