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 –