简体   繁体   English

在php中运行python进行图像处理

[英]Running python in php for image processing

hi everyone I want to run a python script through php in which i've to do image processing and update a database and then use that database in same php program. 大家好,我想通过php运行python脚本,在其中必须进行图像处理并更新数据库,然后在同一php程序中使用该数据库。 Is it feasible ? 可行吗? If yes then how ? 如果是,那怎么办? I am a beginner so apology if the question isn't up to the mark. 我是一个初学者,如果问题没有解决,请您道歉。 Please help me making my first project :) 请帮我做第一个项目:)

you can use exec command to run python script from php 您可以使用exec命令从php运行python脚本

exec(python script_name parameter)

To know more about exec go to this link 要了解有关exec更多信息,请转到此链接

http://php.net/manual/en/function.exec.php http://php.net/manual/zh/function.exec.php

I've used php to call python machine learning script.Try this 我已经用php来调用python机器学习脚本了。

Example for Ubuntu Ubuntu示例

$values=shell_exec('/usr/bin/python two.py '.$ing.'');

Example for Windows Windows示例

$values=shell_exec('C:\Python27\python two.py '.$ing.'');

$ing is the variable passed to the script. $ ing是传递给脚本的变量。 Remember to give the absolute path of python. 记住要给出python的绝对路径。 It was pretty feasible for me. 对我来说这是完全可行的。 But performance mostly depends on your python script as the php just executes the python code 但是性能主要取决于您的python脚本,因为php只是执行python代码

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM