2
我將PDF文件分割爲圖像並且工作正常,但問題是我將PDF文件分割成圖像後大小爲2.5 MB,總大小增加到8 MB。所以我不想增加這些圖像大小,因爲這是服務器上的存儲問題。Ghostscript在分割後增加文件大小PDF
代碼
using (var pdfReader = new PdfReader(fileSavePath))
{
var imagelst = new Pdf2Image(fileSavePath).GetImages(1, pdfReader.NumberOfPages);
foreach (var image in imagelst)
{
imageModal = new ImageModel();
imageModal.FileName = Guid.NewGuid().ToString() + ".png";
image.Save(dirPath + "\\" + imageModal.FileName);
//Using below commented code I can decrease Image size 50 % percent but it creates Image quality problem.
//int newWidth = (int)(image.Width * 0.5);
//int newHeight = (int)(image.Height * 0.5);
//var newImage = ImageHelper.ResizeImage(image, newWidth, newHeight);
//newImage.Save(dirPath + "\\" + imageModal.FileName);
imageModelList.Add(imageModal);
}
}
你是什麼意思的「分裂爲圖像」?你是光柵化它嗎?你使用什麼圖像類型,什麼顏色深度,壓縮等?如果您發佈了完整的ghostscript命令並且還描述了輸入文件包含的內容 - 只有黑/白文本,您可能會得到更多提示。 JPEG照片?所有這些都與你的問題相關, –
刪除C#和asp.net-mvc標籤,因爲沒有相關性。 – Richard
@StefanHegny「拆分爲圖像」意味着我有包含頁數的pdf文件,並將每個頁面轉換爲圖像。我將它保存爲PNG圖像。而我在C#中使用MVC執行的所有事情使用Ghostscript.net –