如何为windows 10设置Fred的ImageMagick脚本并从python运行这些脚本

2024-10-01 07:15:20 发布

您现在位置:Python中文网/ 问答频道 /正文

有人能详细地向我解释一下Fred's ImageMagick Scriptswindows10 64bit中为Fred's ImageMagick Scripts设置的环境以及从python运行这些脚本吗? 我已经安装了带有UNIX bc calculator和ImageMagick的cywin64,并添加了系统变量的路径,下载了textcleaner脚本,并将其转换为.sh,然后尝试从python运行它

import subprocess

cmd = 'textcleaner.sh -g -e stretch -f 25 -o 20 -t 30 -u -s 1 -T -p 20 abbott2.jpg out.png'

subprocess.call(cmd, shell=True)

import subprocess 
bashCommand = "sh textcleaner -g -e normalize -f 5 -o 10 -s 2 C:/Users/RahulNaidu/OneDrive/Desktop/SelvaImages/18420_0.png C:/Users/RahulNaidu/OneDrive/Desktop/SelvaImages/output.png"
process = subprocess.Popen(bashCommand.split(), shell=True, stdout=subprocess.PIPE) 
output, error = process.communicate()

我每次都会遇到一个新错误,所以我需要帮助来解决这个错误


Tags: import脚本cmdtruepngshscriptsfred
1条回答
网友
1楼 · 发布于 2024-10-01 07:15:20

您需要将路径添加到textcleaner,如果这不起作用,则在该路径前面添加bash。后者取决于是否已将路径添加到bash$path环境变量中的脚本中

这对我来说很有用

import subprocess

cmd = 'bash ./textcleaner.sh -g -e stretch -f 25 -o 20 -t 30 -u -s 1 -T -p 20 abbott2.jpg out.png'

subprocess.call(cmd, shell=True)


您可能会收到一条关于找不到bash“type”命令的错误消息。但这不应影响图像的处理

但请注意,我的脚本仅对非商业用途免费。否则,您需要就许可事宜与我联系

请阅读我的主页http://www.fmwconcepts.com/imagemagick/index.php上的信息和使用说明。有一些关于在Windows上运行的文档的链接。另见https://imagemagick.org/discourse-server/viewtopic.php?f=26&t=25910

相关问题 更多 >