gpt4 book ai didi

c# - 无法让 ImageResizer 调整我的 Pdf 大小

转载 作者:太空宇宙 更新时间:2023-11-03 12:49:46 24 4
gpt4 key购买 nike

我刚刚开始使用 ImageResizer 为我的图像创建缩略图,使用下面他们网站上的代码。

private void CreateThumbnail()
{
Dictionary<string, string> versions = new Dictionary<string, string>();
//Define the versions to generate
versions.Add("_thumb", "width=100&height=100&crop=auto&format=jpg"); //Crop to square thumbnail
versions.Add("_medium", "maxwidth=100&maxheight=100&format=jpg"); //Fit inside 400x400 area, jpeg
versions.Add("_large", "maxwidth=1900&maxheight=1900&format=jpg"); //Fit inside 1900x1200 area

//Loop through each uploaded file
foreach (string fileKey in HttpContext.Current.Request.Files.Keys)
{
HttpPostedFile file = HttpContext.Current.Request.Files[fileKey];
if (file.ContentLength <= 0) continue; //Skip unused file controls.

//Get the physical path for the uploads folder and make sure it exists
string uploadFolder = MapPath("~/Images");
if (!Directory.Exists(uploadFolder)) Directory.CreateDirectory(uploadFolder);

//Generate each version
foreach (string suffix in versions.Keys)
{
//Generate a filename (GUIDs are best).
string fileName = Path.Combine(uploadFolder, "AssetID" + suffix);

//Let the image builder add the correct extension based on the output file type
fileName = ImageBuilder.Current.Build(file, fileName, new ResizeSettings(versions[suffix]), false, true);
}
}
}

但是,当我将此代码应用于 Pdf 时,它会崩溃并出现错误“文件可能已损坏、为空或可能包含单个尺寸大于 65,535 像素的 PNG 图像。”我需要进行哪些更改才能调整 Pdf 的大小?我已经阅读了他们的文档,虽然它似乎会从 Pdf 创建缩略图,但这些示例都使用图像。

这是包括 PdfRenderer 在内的插件列表

enter image description here

最佳答案

未安装 PdfiumRenderer 或 PdfRenderer 插件(无论您选择哪个)。因此,主解码器无法解码图像。

您必须安装 PDF 插件才能使用。

PdfiumRenderer 是两者中较好的。

参见 http://imageresizing.net/docs/v4/plugins/pdfiumrenderer

关于c# - 无法让 ImageResizer 调整我的 Pdf 大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36017066/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com