dtyyrt4545 2017-01-04 02:46
浏览 136

将图像作为php脚本的输出,使用python调用它

Here I am trying to process an image using a php script textcleaner. I have to run this php script in my other part of python project.I'm confused in getting the output image from php script textcleaner(I get this script from here :

http://www.fmwconcepts.com/imagemagick/textcleaner/index.php )

and my code in python for running it is as ..

import subprocess
proc = subprocess.Popen("php textcleaner.php  -g -e none -f 10 -o 5   src.jpg out.jpg", shell=True, stdout=subprocess.PIPE)
script_response = proc.stdout.read()

Here textcleaner.php is php script file and after that (-g -e none -f 10 -o 5) are the arguments those i want to pass to script(textcleaner) for processing my image(src.jpg) and the output image should be out.jpg

If any one used this before or know how to get the output in out.jpg as an image please tell me .

I also checked script_response by using print() but it gives me the help menu of textcleaner .

  • 写回答

1条回答 默认 最新

  • dongzhong2018 2017-01-04 17:02
    关注

    This answer Running bash script from within python may point you in the right direction - I do not use Python or bash so can not help further.

    import subprocess
    print "start"
    subprocess.call("textcleaner -g -e none -f 10 -o 5 src.jpg out.jpg")
    print "end"
    

    Do not forget to make textcleaner executable e.g 777 or 755 may work. I would rename textcleaner to textcleaner.sh and use textcleaner.sh in your code. It just reminds you what the file type is.

    评论

报告相同问题?

悬赏问题

  • ¥15 processing提取音乐节奏
  • ¥15 python进程启动打包问题
  • ¥15 gg加速器加速游戏时,提示不是x86架构
  • ¥15 python按要求编写程序
  • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入
  • ¥20 XP系统在重新启动后进不去桌面,一直黑屏。
  • ¥15 opencv图像处理,需要四个处理结果图
  • ¥15 无线移动边缘计算系统中的系统模型
  • ¥15 深度学习中的画图问题
  • ¥15 java报错:使用mybatis plus查询一个只返回一条数据的sql,却报错返回了1000多条