如何在python中的spyder上运行image magick textcleaner命令 [英] how to run image magick textcleaner commands on spyder in python

查看:173
本文介绍了如何在python中的spyder上运行image magick textcleaner命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to run the Imagemagick bash shell script, textcleaner, from Spyder IDE with the following syntax, but I was not able to get it to work.

导入操作系统 os.system("textcleaner -g -e normalize -f 30 -o 12 -s 2 in.png out.png")

import os os.system("textcleaner -g -e normalize -f 30 -o 12 -s 2 in.png out.png")

推荐答案

Textcleaner是我的Imagemagick bash shell脚本.我还没有尝试从Python运行它.但这应该可以在Python 3子进程中使用.

Textcleaner is my Imagemagick bash shell script. I have not tried to run it from Python. But this should work using Python 3 subprocess.

import subprocess

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

subprocess.call(cmd, shell=True)

您可能需要以bash和/或textcleaner的完整路径为textcleaner开头.另外,您可能需要提供输入和输出的完整路径.另外,请确保编辑脚本的权限以使其可执行(chmod u + x textcleaner).请参阅 http://www.fmwconcepts.com/imagemagick/index.php

You may need to preface textcleaner with bash and/or the full path to textcleaner. Also you may need to provide the full paths to the input and output. Also be sure to edit the script's permissions to make it executable (chmod u+x textcleaner). See my Pointers for Use at http://www.fmwconcepts.com/imagemagick/index.php

这篇关于如何在python中的spyder上运行image magick textcleaner命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆