如何在python中的spyder上运行image magick textcleaner命令

2024-10-01 02:36:33 发布

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

我尝试使用以下语法从Spyder IDE运行ImageMagickBashShell脚本textcleaner,但我无法使其正常工作。在

导入操作系统 操作系统(“textcleaner-g-e规格化-f 30-o 12-s 2英寸.png输出.png“)


Tags: 脚本png语法idespyder英寸规格化textcleaner
1条回答
网友
1楼 · 发布于 2024-10-01 02:36:33

Textcleaner是我的Imagemagick bash shell脚本。我没有尝试从Python运行它。但这应该可以使用python3子进程来实现。在

import subprocess

cmd = 'textcleaner -g -e normalize -f 30 -o 12 -s 2 in.png out.png'

subprocess.call(cmd, shell=True)

您可能需要在textcleaner之前使用bash和/或textcleaner的完整路径。此外,您可能需要提供输入和输出的完整路径。还要确保编辑脚本的权限以使其可执行(chmodu+xtextcleaner)。请参阅我在http://www.fmwconcepts.com/imagemagick/index.php上使用的指针

相关问题 更多 >