如何通过 ImageMagick 的转换命令覆盖 Windows 的转换命令?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4481573/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to override Windows' convert command by ImageMagick's one?
提问by vettipayyan
In Windows, a command called convert
is used to convert the filesystems. When you type convert
, it will ask you to specify a filesystem.
在Windows 中,一个名为的命令convert
用于转换文件系统。当您键入 时convert
,它会要求您指定一个文件系统。
In ImageMagick, convert
command is used for image processing.
在ImageMagick 中,convert
命令用于图像处理。
The problem is, even after setting the environment variable for ImageMagick convert
, the tool doesn't get invoked. It calls only the Windows convert
command. How to override that?
问题是,即使为 ImageMagick 设置了环境变量convert
,该工具也不会被调用。它只调用 Windowsconvert
命令。如何覆盖它?
采纳答案by Abhi
Did you logoff and login?
您是否注销并登录?
Or specify the Imagemagick's convert by providing the complete path
或者通过提供完整路径来指定 Imagemagick 的转换
回答by Tom Robinson
This is an old question, but the current solution with ImageMagick 7 is to use the "magick" command in place of "convert".
这是一个老问题,但 ImageMagick 7 当前的解决方案是使用“magick”命令代替“convert”。
回答by mgambella
This is an old question, but I encountered this problem today, and this is my solution in Windows 7.
这是一个老问题,但我今天遇到了这个问题,这是我在Windows 7中的解决方案。
Windows convert.exe is located in folder C:\Windows\System32
, so you have to modify the Windows PATH variable by putting the ImageMagick path (for example C:\Libs\ImageMagick-6.8.8-4
) before the path that loads System32
(ie. %SystemRoot%\System32
).
Windows convert.exe 位于文件夹中C:\Windows\System32
,因此您必须通过将 ImageMagick 路径(例如C:\Libs\ImageMagick-6.8.8-4
)放在加载路径System32
(即)之前来修改 Windows PATH 变量%SystemRoot%\System32
。
This will cause all ImageMagick executables to take priority over any similarly named system executables, which should do what you want but may cause unexpected behaviour.
这将导致所有 ImageMagick 可执行文件优先于任何类似命名的系统可执行文件,后者应该可以执行您想要的操作,但可能会导致意外行为。
Also, when you want to use the system convert.exe, you'll have to specify the full pathname such as C:\Windows\System32\convert.exe
.
此外,当您想使用系统 convert.exe 时,您必须指定完整路径名,例如C:\Windows\System32\convert.exe
.
回答by Tymric
Renaming the ImageMagick convert.exe
worked well for me.
重命名 ImageMagickconvert.exe
对我来说效果很好。
I didn't like using full path each time, and changing the system PATH variable isn't possible for me on the work PC.
我不喜欢每次都使用完整路径,而且我无法在工作 PC 上更改系统 PATH 变量。
After renaming convert.exe
to imgconvert.exe
, no other changes were needed. You could now use the new command anywhere from the command line without it being confused with the intrinsic Windows file system convert
重命名convert.exe
为 后imgconvert.exe
,无需其他更改。您现在可以在命令行的任何位置使用新命令,而不会与固有的 Windows 文件系统混淆convert
Edit: As of version 7.0, the command is now magick.exe
, which no longer clashes with any native windows commands. So downloading the latest version if possible should solve the problem as well.
编辑:从 7.0 版开始,命令现在是magick.exe
,不再与任何本机 Windows 命令冲突。因此,如果可能,下载最新版本也应该可以解决问题。
回答by Jared Beach
In powershell you can run this: $env:Path = "C:\path-to-convert\;$env:Path"
在powershell中你可以运行这个: $env:Path = "C:\path-to-convert\;$env:Path"
Now the imagemagick convert exe gets found because it comes first in the path.
现在找到了 imagemagick convert exe,因为它首先出现在路径中。