POV-Ray : Newsgroups : povray.programming : Executing povray using PHP : Re: Executing povray using PHP Server Time
28 Sep 2024 11:03:55 EDT (-0400)
  Re: Executing povray using PHP  
From: pan
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

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