asp.net - Windows 上的 ImageMagick 转换错误 "Invalid Parameter"

标签 asp.net windows imagemagick

我正在尝试使用来自 ASP.NET 网站的 ImageMagick 命令行工具将 PDF 文档转换为 PNG 文件。我创建了一个新的 shell 进程并执行以下命令:

convert -density 96x96 "[FileNameAndPath].pdf" "[FileNameAndPath].png"

当使用 VS 的 ASP.NET 开发服务器在我的本地计算机上测试网站时,该命令运行良好,手动输入 shell 时该命令也运行良好。从 ASP.NET 中以编程方式创建的 shell 运行时,出现以下错误消息:

Invalid Parameter - 96x96

有人知道为什么会发生这种情况以及该怎么办吗?

我在使用与 ASP.NET 进程不同的用户帐户通过 RDP 登录服务器时测试了该命令。我使用了与本地计算机上完全相同的 ImageMagick 和 Ghostscript 安装文件,并在安装过程中激活了将 ImageMagick 安装路径添加到环境变量。从那以后服务器没有重新启动。

最佳答案

convert也是将 FAT 文件系统转换为 NTFS 的 Windows 可执行文件的名称。当您不指定可执行文件的完整路径时,引用:

...the system first searches the current working directory and then searches the path environment variable, examining each directory from left to right, looking for an executable filename that matches the command name given.

“C:\Windows\System32”通常出现在 %PATH% 变量的开头,导致 Windows 转换实用程序启动,如预期的那样失败并出现“无效参数”错误。

尝试像这样指定 ImageMagick 的 convert.exe 的完整路径:

"C:\Program Files\ImageMagick\convert.exe" -density 96x96 "path_and_filename.pdf" "path_and_filename.png"

关于asp.net - Windows 上的 ImageMagick 转换错误 "Invalid Parameter",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3060205/

相关文章:

windows - 进程句柄重用的频率

c# - 根据 future 日期自动删除 Azure 中的 Blob 文件

asp.net - 使用 jQuery 显示 ashx 图像?

windows - "findstr"在 VBScript 中总是返回失败

windows - IE 网络浏览器控制资源 ://usage

ImageMagick 命令行 : converting PDF to high definition images

ruby-on-rails - 回形针 | ImageMagick - 无法使用自定义高度调整图像大小

windows - 如何使用管道(ffmpeg + imagemagick)构建视频缩略图表?

c# - 如何使用 C#.Net 检索我的公共(public) IP 地址?

jquery - 在.Net MVC 5的同一页面中创建 "One to many"的 View