SOLVED: Solution ------------------------------------------------------------------
I would like to execute the function getimagesize()
from the PHP standard library in a Python script. The function must be passed an image path from Python.
I know how to run a php script in Python, but I can't figure out how to pass an argument from Python -> PHP and then get the result back into Python.
Here is what I have in the Python Script:
def php_script_runner(script_path):
p = subprocess.Popen(['php', script_path], stdout=subprocess.PIPE)
result = p.communicate()[0]
return result
Here is what I have in the PHP file (I am not sure how to pass an argument to it):
<?php getimagesize() ?>
How would I pass an argument to 'get_image_size.php'
and have it return the result in Python for further processing?
I would like to further implement this idea for other custom PHP functions. The main goal of this question is not only to find the size of an image, but to be able to use this for other functions in the future that are php intensive.
The main goal of this is to determine:
- How to call a PHP script in Python
- How to send an agrument to a PHP script from Python
- How to parse the output of the PHP script back into Python