POV-Ray : Newsgroups : povray.programming : Executing povray using PHP Server Time
22 Dec 2024 12:41:55 EST (-0500)
  Executing povray using PHP (Message 1 to 9 of 9)  
From: bbossard
Subject: Executing povray using PHP
Date: 20 Oct 2004 00:20:00
Message: <web.4175e6d17aabcab5e75460680@news.povray.org>
Anyone who could lend a hand with this, your help is greatly appreciated in
advance.

I'm working on a website that will dynamically create a .pov file based on
user input, and then execute povray on it and return the image to the user.
 The following code is a simplified version of the idea.

If I run this code by typing

php test.php

it works fine, but if I put it in a web directory, and then try to execute
by typing

localhost/test.php

as my browser address, the code creates the .pov file, but never executes
the povray command.  I read in another post that maybe you have to compile
the povray source code using the directive --without-x to force it not to
use X, but I tried this and it still does not work.  Can anybody get this
to work on their webserver?  Is it a povray problem, or maybe something
with the way I have Apache configured?

Thanks,

Brad


<?
// test.php

$pov_file_pointer = fopen("test.pov", "w");
if (!$pov_file_pointer) die ('Unable to create POV file.');


fwrite($pov_file_pointer,"#include "colors.inc"n");
fwrite($pov_file_pointer,"background { color Black }n");
fwrite($pov_file_pointer,"global_settings { assumed_gamma 2.2 }nn");

fwrite($pov_file_pointer,"camera {n");
fwrite($pov_file_pointer,"tlocation < 0.0, 0.0, 30.0 >n");
fwrite($pov_file_pointer,"tlook_at < 0.0, 0.0, 0.0 >");
fwrite($pov_file_pointer,"}n");

fwrite ($pov_file_pointer,"cylinder n");
fwrite ($pov_file_pointer,"{n");
fwrite ($pov_file_pointer,"t<30.0 ,30.0, 0.0> n");
fwrite ($pov_file_pointer,"t<-30.0, 30.0, 0.0> n");
fwrite ($pov_file_pointer,"t100.0 n");
fwrite ($pov_file_pointer,"topen n");
fwrite ($pov_file_pointer,"tfinish { n");
fwrite ($pov_file_pointer,"ttambient 1.0n");
fwrite ($pov_file_pointer,"ttdiffuse 0.8n");
fwrite ($pov_file_pointer,"ttphong 1n");
fwrite ($pov_file_pointer,"t}n");
fwrite ($pov_file_pointer,"tpigment { color red 0 green 0 blue 1 }n");
fwrite ($pov_file_pointer,"}n");

fclose($pov_file_pointer);

exec ('povray test.pov -Otest.png -GAtest.out');

?>


Post a reply to this message

From: pan
Subject: Re: Executing povray using PHP
Date: 20 Oct 2004 08:26:41
Message: <41765981@news.povray.org>
"bbossard" <bbo### [at] hotmailcom> wrote in message
news:web.4175e6d17aabcab5e75460680@news.povray.org...
> Anyone who could lend a hand with this, your help is greatly appreciated
in
> advance.
>
> I'm working on a website that will dynamically create a .pov file based on
> user input, and then execute povray on it and return the image to the
user.
>  The following code is a simplified version of the idea.
>

If this helps;

on FreebSD 4.9 using the povray-3.5 ports package

I initiate a pov trace via a .php file that calls
 a CLI  .ph file
(Since PHP 4.3.0 the CLI SAPI is no longer experimental
and the option --enable-cli is on by default)

I call cli php files .ph to differentiate from .php
don't need to configure apache to handle these
.ph are just scripts that can run with normal bang headers

this allows a script such as: [watch out for word wrap] (on hdd in dir above
htdocs)

// file testpov.ph
#!/usr/local/bin/php -q

<?php

$command = "/usr/local/bin/povray
+I/usr/local/apache/htdocs/npqr_net/pov/box.pov
  +H600 +W800 -display 0:3 -D +A +FN8
+o/usr/local/apache/htdocs/npqr_net/pov/box.png
  -V -GA/usr/local/apache/htdocs/npqr_net/pov/boxtest
 /usr/local/share/povray-3.5/ini/povray.ini > /dev/null 2>&1 &";

exec($command);

?>

note the  -display 0:3  switch   this takes care of the --without-x problem
note the output redirection (> /dev/null 2>&1 &)  keeps in background and
no banner display, etc.

I call the cli .ph file with something like this:

//testpov.php
<?php
 $command = "/usr/local/phpcli/testpov.ph";
 exec($command);
?>

*** Check your povray.conf file and povray.ini file
*** Make sure you have libpng,libjpeg, etc. installed

Works easy enough.

pan


Post a reply to this message

From: Warp
Subject: Re: Executing povray using PHP
Date: 20 Oct 2004 09:19:05
Message: <417665c9@news.povray.org>
It's important to tell which version of POV-Ray you are using. It makes
a big difference in this specific case.

-- 
plane{-x+y,-1pigment{bozo color_map{[0rgb x][1rgb x+y]}turbulence 1}}
sphere{0,2pigment{rgbt 1}interior{media{emission 1density{spherical
density_map{[0rgb 0][.5rgb<1,.5>][1rgb 1]}turbulence.9}}}scale
<1,1,3>hollow}text{ttf"timrom""Warp".1,0translate<-1,-.1,2>}//  - Warp -


Post a reply to this message

From: pan
Subject: Re: Executing povray using PHP
Date: 20 Oct 2004 10:59:21
Message: <41767d49@news.povray.org>
"Warp" <war### [at] tagpovrayorg> wrote in message
news:417665c9@news.povray.org...
>   It's important to tell which version of POV-Ray you are using. It makes
> a big difference in this specific case.
>

Absent quoted and attributed references,
your ambiguity as to whom you are replying
impels me to assume it is I.

Therefore, my examples employ povray 3.5b

Pan "if it is not I, then nevermind" Latella


Post a reply to this message

From: Warp
Subject: Re: Executing povray using PHP
Date: 20 Oct 2004 11:04:07
Message: <41767e67@news.povray.org>
pan <pan### [at] syixcom> wrote:
> your ambiguity as to whom you are replying

  There's no ambiguity since the 'References' header of my article tells
(the newsreader) perfectly who I am replying to.

-- 
plane{-x+y,-1pigment{bozo color_map{[0rgb x][1rgb x+y]}turbulence 1}}
sphere{0,2pigment{rgbt 1}interior{media{emission 1density{spherical
density_map{[0rgb 0][.5rgb<1,.5>][1rgb 1]}turbulence.9}}}scale
<1,1,3>hollow}text{ttf"timrom""Warp".1,0translate<-1,-.1,2>}//  - Warp -


Post a reply to this message

From: Slime
Subject: Re: Executing povray using PHP
Date: 20 Oct 2004 11:09:25
Message: <41767fa5@news.povray.org>
>   There's no ambiguity since the 'References' header of my article tells
> (the newsreader) perfectly who I am replying to.

Annoyingly, this hasn't been the case with a number of posts I've been
seeing recently (that is, people are replying to the first post in the
thread rather than the post they mean to reply to). I wonder if the web
interface doesn't allow people to reply to specific posts? Or maybe since it
has a linear layout, some people don't know the difference?

Assuming it's the web interface which is confusing people, I wish it would
be changed to a tree layout like a newsreader has, in order to help avoid
this confusion.

 - Slime
 [ http://www.slimeland.com/ ]


Post a reply to this message

From: pan
Subject: Re: Executing povray using PHP
Date: 20 Oct 2004 11:28:06
Message: <41768406@news.povray.org>
You might be right, however MS newsreaders are notorious
for ill implemented threading.

Plus, I'm lazy and didn't want to do all the mouse clicks to
view the reference header.

Pan "I shot a comment into the air ... "


Post a reply to this message

From: bbossard
Subject: Re: Executing povray using PHP
Date: 20 Oct 2004 12:40:00
Message: <web.41769427ce5ae908e75460680@news.povray.org>
Thank you pan and Warp for your replies.  I figured out the problem after
almost completing this post, so I guess I will just finish it and maybe
someone else will find it helpful.

First off, I am using the very latest version of povray I could get,
v.3.6.1, built from source.  I have not been a povray user for very long,
but would like my website to embody the open source spirit, so povray
looked like the best option.

Secondly, I would prefer not to have to change my operating system to BSD,
although I appreciate you mentioning that it does work on that system, and
if I cannot resolve this problem any other way, I might have to consider
it.

Thirdly, I started tinkering around with a few of the tips provided by pan,
and came up with some new findings.  The display option must be depricated
or the syntax has changed, it was not recognized by 3.6.1.  I also added
switch to run it in backgroud, and then added a echo statement before the
exec statement.

I have attached my updated code to this post... It runs from the
command-line fine (i.e.  php test.php).  If I try to execute it from a web
browser though, the page will display

sh: line 1: povray: command not found

ahhhh.... Just figured out the problem, the user apache doesn't have the
/usr/local/bin directory in it's path or something, so you must change the
exec line to

echo exec ('/usr/local/bin/povray test.pov +H600 +W800 -display 0:3 -D +A
+FN8 -Otest.png -GAtest.out /dev/null 2>&1 &');

Sweet, works now, thanks to everyone that posted.  Like I said, maybe this
will help someone in the future.

Brad


<?
// test.php

$pov_file_pointer = fopen("test.pov", "w");
if (!$pov_file_pointer) die ('Unable to create POV file.');


fwrite($pov_file_pointer,"#include "colors.inc"n");
fwrite($pov_file_pointer,"background { color Black }n");
fwrite($pov_file_pointer,"global_settings { assumed_gamma 2.2 }nn");

fwrite($pov_file_pointer,"camera {n");
fwrite($pov_file_pointer,"tlocation < 0.0, 0.0, 30.0 >n");
fwrite($pov_file_pointer,"tlook_at < 0.0, 0.0, 0.0 >n");
fwrite($pov_file_pointer,"}n");

fwrite ($pov_file_pointer,"cylindern");
fwrite ($pov_file_pointer,"{n");
fwrite ($pov_file_pointer,"t<30.0 ,30.0, 0.0>n");
fwrite ($pov_file_pointer,"t<-30.0, 30.0, 0.0>n");
fwrite ($pov_file_pointer,"t100.0 n");
fwrite ($pov_file_pointer,"topen n");
fwrite ($pov_file_pointer,"tfinish { n");
fwrite ($pov_file_pointer,"ttambient 1.0n");
fwrite ($pov_file_pointer,"ttdiffuse 0.8n");
fwrite ($pov_file_pointer,"ttphong 1n");
fwrite ($pov_file_pointer,"t}n");
fwrite ($pov_file_pointer,"tpigment { color red 0 green 0 blue 1 }n");
fwrite ($pov_file_pointer,"}n");

fclose($pov_file_pointer);

echo exec ('povray test.pov +H600 +W800 -display 0:3 -D +A +FN8 -Otest.png
-GAtest.out /dev/null 2>&1 &');

?>


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: Executing povray using PHP
Date: 13 Dec 2004 09:49:07
Message: <41bdabe3$1@news.povray.org>
In article <web.4175e6d17aabcab5e75460680@news.povray.org> , "bbossard" 
<bbo### [at] hotmailcom> wrote:

> Anyone who could lend a hand with this, your help is greatly appreciated in
> advance.
>
> I'm working on a website that will dynamically create a .pov file based on
> user input, and then execute povray on it and return the image to the user.
>  The following code is a simplified version of the idea.
>
> If I run this code by typing
>
> php test.php
>
> it works fine, but if I put it in a web directory, and then try to execute
> by typing
>
> localhost/test.php
>
> as my browser address, the code creates the .pov file, but never executes
> the povray command.  I read in another post that maybe you have to compile
> the povray source code using the directive --without-x to force it not to
> use X, but I tried this and it still does not work.  Can anybody get this
> to work on their webserver?  Is it a povray problem, or maybe something
> with the way I have Apache configured?

This is the wrong group for this question.  This group is for discussion of
the POV-Ray source code.  Questions about using the POV-Ray should be asked
in either povray.general or povray.newusers.  Platform specific questions
should be asked in povray.windows, povray.unix or povray.macintosh .

    Thorsten

____________________________________________________
Thorsten Froehlich
e-mail: mac### [at] povrayorg

I am a member of the POV-Ray Team.
Visit POV-Ray on the web: http://mac.povray.org


____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.