Cylinderize
Cylinderize
Specifically looking at the URL:
http://www.fmwconcepts.com/imagemagick/ ... /index.php
I am trying to use/implement this script using PHP (either PHP 4 OR PHP5 it doesn't matter)
I am extremely interested in getting this up and running but hitting a bit of a wall.
My IM installation is:
"Version: ImageMagick 6.5.7-9 2009-11-19 Q16 http://www.imagemagick.org Copyright: Copyright (C) 1999-2009 ImageMagick Studio LLC"
I've downloaded the cylinderize.sh script, uploaded it to my hosting, then tried to call it using the exec("...") method.
I found examples on this forum trying to explain how to load the script in PHP and I gather that I have to complete parts of the script with paths and directories to get it working.
Can someone hand-hold me through the process of getting it running? I know it's a big ask, but I've not seen (40mins - 1 hour of Googling) any PHP examples using this Cylinderize script..
So I guess if anyone wants to help the first question (dummy question) is:
1.. What is my path to IM ? (it's a shared host and I had them install it for me).
http://www.fmwconcepts.com/imagemagick/ ... /index.php
I am trying to use/implement this script using PHP (either PHP 4 OR PHP5 it doesn't matter)
I am extremely interested in getting this up and running but hitting a bit of a wall.
My IM installation is:
"Version: ImageMagick 6.5.7-9 2009-11-19 Q16 http://www.imagemagick.org Copyright: Copyright (C) 1999-2009 ImageMagick Studio LLC"
I've downloaded the cylinderize.sh script, uploaded it to my hosting, then tried to call it using the exec("...") method.
I found examples on this forum trying to explain how to load the script in PHP and I gather that I have to complete parts of the script with paths and directories to get it working.
Can someone hand-hold me through the process of getting it running? I know it's a big ask, but I've not seen (40mins - 1 hour of Googling) any PHP examples using this Cylinderize script..
So I guess if anyone wants to help the first question (dummy question) is:
1.. What is my path to IM ? (it's a shared host and I had them install it for me).
Re: Cylinderize
There are some examples of php and Imagemagick on my site which if you can find it answer all these questions
Find out the path to ImageMagick
1.Download the script and upload it to your server.
2.Change the permissions to 755 on the script
3.Write your php code like this using the full path to the script
Find out the path to ImageMagick
Code: Select all
<?php
echo "<pre>";
system("type convert");
echo "</pre>";
?>
or
<?php
echo "<pre>";
system('which convert',$path); print_r($path);
echo "</pre>";
?>
2.Change the permissions to 755 on the script
3.Write your php code like this using the full path to the script
Code: Select all
<?php
// Run the script
exec("/FULL PATH TO CYLINDERIZE/cylinderize.sh input output 2>&1", $array);
//Display any errors
echo "<br>".print_r($array)."<br>";
echo "</pre>";
?>
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Cylinderize
to get your path, try
<?php
echo "<pre>";
system("which -a convert");
echo "</pre>";
?>
or
<?php
echo "<pre>";
system("type -a convert");
echo "</pre>";
?>
typically it will be /usr/local/bin or /usr/bin, unless they custom installed it somewhere else just for you.
To convert the script, see pointers at http://www.fmwconcepts.com/imagemagick/index.php for using with PHP exec. Be sure the script is made executable (step 3) and also make sure to follow steps 5) and 6) to set the IM command alias so you don't have to edit every IM command in the script.
To set up your PHP command something like
<?php
exec("bash pathto/cylinderize -m vertical -p 20 pathto/img5967.jpg pathto/img5967_cyl.jpg 2>&1",$out,$returnval);
foreach($out as $text)
{echo "$text<br>";}
?>
The bash may or may not be needed. The 2>&1 and $out and foreach... echo... will allow the script to print any error messages or textual information that might help you debug. That can be removed later if you want.
<?php
echo "<pre>";
system("which -a convert");
echo "</pre>";
?>
or
<?php
echo "<pre>";
system("type -a convert");
echo "</pre>";
?>
typically it will be /usr/local/bin or /usr/bin, unless they custom installed it somewhere else just for you.
To convert the script, see pointers at http://www.fmwconcepts.com/imagemagick/index.php for using with PHP exec. Be sure the script is made executable (step 3) and also make sure to follow steps 5) and 6) to set the IM command alias so you don't have to edit every IM command in the script.
To set up your PHP command something like
<?php
exec("bash pathto/cylinderize -m vertical -p 20 pathto/img5967.jpg pathto/img5967_cyl.jpg 2>&1",$out,$returnval);
foreach($out as $text)
{echo "$text<br>";}
?>
The bash may or may not be needed. The 2>&1 and $out and foreach... echo... will allow the script to print any error messages or textual information that might help you debug. That can be removed later if you want.
Re: Cylinderize
Thats Ok Fred - at least our answers were very similar
Re: Cylinderize
Bonzo - yes your pages are the top favourite for me in this topic - Must of read 2/3 of the pages on there - can i just say a huge thank you for all of your help via those pages - it really opened my eyes.
I'll post back once I've had a chance to try the methods posted by you both - thanks again
I'll post back once I've had a chance to try the methods posted by you both - thanks again
Re: Cylinderize
Ok so:
Gives an output of:
I've shortened the script name because :
a) i struggle spelling cylinderize (at the best of times, least after staring at small screen for 8 hours)
b) quicker to type
Code: Select all
exec("bash cyl.sh -m vertical -p 20 paul.png warped_paul.png 2>&1",$out,$returnval);
foreach($out as $text)
{
echo "$text<br>";
}
Code: Select all
cyl.sh: line 174: type: cyl.sh: not found
dirname: too few arguments
Try `dirname --help' for more information.
basename: too few arguments
Try `basename --help' for more information.
I've shortened the script name because :
a) i struggle spelling cylinderize (at the best of times, least after staring at small screen for 8 hours)
b) quicker to type
Re: Cylinderize
Line 174 from cyl.sh:
Code: Select all
174: PROGNAME=`type $0 | awk '{print $3}'` # search for executable on path
175: PROGDIR=`dirname $PROGNAME` # extract directory of program
176: PROGNAME=`basename $PROGNAME` # base name of program
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Cylinderize
You did not provide the full path to cyl.sh? I presume you renamed the file to cyl.sh from cylinderize or cylinderize.sh. Be sure the .sh is appended if that is exactly the file name.
exec("bash cyl.sh -m vertical -p 20 paul.png warped_paul.png 2>&1",$out,$returnval);
cyl.sh: line 174: type: cyl.sh: not found
dirname: too few arguments
Try also without the bash (that is try both ways -- with and without bash).
Re: Cylinderize
As Fred says you need the full path ro cyl.sh from the root so running the code below should give you the directory and then add the cyl.sh part.
Your code will then be something lik:
Its good to know my site has been of use.
Code: Select all
<?php
$docRoot = getenv("DOCUMENT_ROOT");
echo $docRoot;
?>
Code: Select all
exec("bash /user/public/folder/cyl.sh -m vertical -p 20 paul.png warped_paul.png 2>&1",$out,$returnval);
foreach($out as $text)
{
echo "$text<br>";
}
Re: Cylinderize
You guys are the best.
This forum is probably the fastest, most efficient and well educated resource i think i've ever visited.
Ok so my entire script:
Is working perfectly - thank you a million times - both of you!
This forum is probably the fastest, most efficient and well educated resource i think i've ever visited.
Ok so my entire script:
Code: Select all
<?php$docRoot = getenv("DOCUMENT_ROOT");
//echo $docRoot;
exec("bash ".$docRoot."/create/cyl.sh -m vertical -p 20 paul.png warped_paul.png 2>&1",$out,$returnval);
foreach($out as $text)
{
echo "$text<br>";
}
?>