palloquin wrote:Hi Fred,
I'm getting stuck on just having too limited PHP knowledge... Do you know of an example out there somewhere that is actually a full PHP page doing something with one of your scripts? I'm sure I can adapt that to get it to work with your text scripts... It's just that first step....
Thank you!!!
See user Bonzo's web site Rubblewebs at
http://www.rubblewebs.co.uk/index.php. But I do not know if he has any examples using my scripts.
The main issues are identified on my home page:
Pointers for use:
1)Download the script
2)Change the name to add or remove the .sh as desired when running
3)Set the script to executable (chmod u+x)
4)Edit the script to add the full path to convert, identify and any other IM command
5)Edit the script to change the default directory (found after the defaults section) from dir="." to dir="/tmp"
6)In the exec command use bash /fullpathto/scriptname(.sh) arguments /fullpathto/inputimage /fullpathto/outputimage.
7)Note that "bash" may or may not be necessary
The critical one is step 4. That can be a lot of work to find every command and put the full path to it. I have been working on developing changes to my scripts to help in this regard, but I have not had time to go about editing every script. But here is a quick fix.
Find out your path to IM via
which convert
In PHP, use
<?php
echo "<pre>";
system("which -a convert");
echo "</pre>";
?>
Then edit the script (it is simple text file) to add just below the line under the argument defaults where it says
# set directory for temporary files
dir="." # suggestions are dir="." or dir="/tmp"
and put the following:
imdir="/usr/local/bin"
# set up aliases to IM functions
if [ "$imdir" != "" ]; then
alias animate="$imdir/animate"
alias compare="$imdir/compare"
alias composite="$imdir/composite"
alias conjure="$imdir/conjure"
alias convert="$imdir/convert"
alias display="$imdir/display"
alias identify="$imdir/identify"
alias import="$imdir/import"
alias mogrify="$imdir/mogrify"
alias montage="$imdir/montage"
alias stream="$imdir/stream"
fi
Replace imdir=... with your path to IM from which convert.
Then follow the remaining directions from above.
Let me know if you still have trouble. Show me you PHP exec command if still having trouble.
Fred
P.S.
Here is one example:
<?php
exec("bash /Users/fred/Applications/bin/cylinderize -m vertical -p 20 img5967.jpg img5967_cyl.jpg 2>&1",$out,$returnval);
foreach($out as $text)
{echo "$text<br>";}
?>
The 2>&1 and $out allow any error messages to captured. The foreach then prints each line of the messages.
This is useful for debugging, but is not necessary afterwards.
Depending upon your PHP and system setup, the bash and/or the path to your script may or may not be necessary (as well as full paths to your images depending upon where they are located)