Page 1 of 1

Please hELp me to edit this code..

Posted: 2011-12-30T07:25:28-07:00
by sriducati
Hello webmasters ,

Iam trying to desighn image magick code using "variables" to accept input from users...here is my code

Code: Select all


$size=$_POST["size"];
$label=$_POST["label"];
$font=$_POST["font"];

$cmd = " -background transparent -font $font -pointsize $size label:$label -stroke black -strokewidth 2 ".
"  \( -clone 0 -tile \"animated_water.gif[0]\" -stroke black -strokewidth 2 -gravity center -annotate +0+0 $label \) ".
"  \( -clone 0 -tile \"animated_water.gif[1]\" -stroke black -strokewidth 2 -gravity center -annotate +0+0 $label \) ".
"  -delete 0 -set delay 15 -loop 0 -trim +repage -layers Optimize ";
$array=array();
echo "<pre>";
exec("convert $cmd masked.gif 2>&1", $array);
echo "<br>".print_r($array)."<br>";
echo "</pre>";
echo "<img src='masked.gif'>";
As you can see on the screen

Code: Select all

$size=$_POST["size"];
$label=$_POST["label"];
$font=$_POST["font"]; 
are three variable that i have used ,,,code works fine ... BUT NOW I NEED TO CREATE one more VARIABLE for image "animated_water.gif" please help me to edit this code on how to create variable for image...????

Re: Please hELp me to edit this code..

Posted: 2011-12-30T15:55:47-07:00
by Bonzo
Not quite sure what you mean; does this work?

Code: Select all

$size=$_POST["size"];
$label=$_POST["label"];
$font=$_POST["font"];

$image = 'animated_water.gif';

$cmd = " -background transparent -font $font -pointsize $size label:$label -stroke black -strokewidth 2 ".
"  \( -clone 0 -tile \"$image[0]\" -stroke black -strokewidth 2 -gravity center -annotate +0+0 $label \) ".
"  \( -clone 0 -tile \"$image[1]\" -stroke black -strokewidth 2 -gravity center -annotate +0+0 $label \) ".
"  -delete 0 -set delay 15 -loop 0 -trim +repage -layers Optimize ";
$array=array();
echo "<pre>";
exec("convert $cmd masked.gif 2>&1", $array);
echo "<br>".print_r($array)."<br>";
echo "</pre>";
echo "<img src='masked.gif'>";

Re: Please hELp me to edit this code..

Posted: 2011-12-30T23:05:57-07:00
by sriducati
Hello Bonzo,

Thanks alot for your reply well Your attempt is good but the code did not work..this is the error message

Code: Select all

  [0] => convert: unable to open image `a': No such file or directory.
    [1] => convert: unable to open image `n': No such file or directory.
please help me to fix this.

Re: Please hELp me to edit this code..

Posted: 2012-01-01T13:05:29-07:00
by Bonzo
It is picking the characters from the filename and not the frames from the file. I will look into it when I get time.

Re: Please hELp me to edit this code..

Posted: 2012-01-02T14:23:17-07:00
by Bonzo
This will work:

Code: Select all

$size=$_POST["size"];
$label=$_POST["label"];
$font=$_POST["font"];

$image0 = 'animated_water.gif[0]';
$image1 = 'animated_water.gif[1]';

$cmd = " -background transparent -font $font -pointsize $size label:$label -stroke black -strokewidth 2 ".
"  \( -clone 0 -tile $image0 -stroke black -strokewidth 2 -gravity center -annotate +0+0 $label \) ".
"  \( -clone 0 -tile $image1 -stroke black -strokewidth 2 -gravity center -annotate +0+0 $label \) ".
"  -delete 0 -set delay 15 -loop 0 -trim +repage -layers Optimize ";
$array=array();
echo "<pre>";
exec("convert $cmd masked.gif 2>&1", $array);
echo "<br>".print_r($array)."<br>";
echo "</pre>";
echo "<img src='masked.gif'>";