0

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 .

2
  • Your first mistake is that is a bash script and not php code. Commented Jan 4, 2017 at 12:28
  • can you please tell me how can i execute it in my python program Commented Jan 4, 2017 at 15:40

1 Answer 1

0

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks to you for your kind help

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.