Please hELp me to edit this code..

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
sriducati
Posts: 28
Joined: 2011-11-28T08:11:59-07:00
Authentication code: 8675308

Please hELp me to edit this code..

Post 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...????
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Please hELp me to edit this code..

Post 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'>";
sriducati
Posts: 28
Joined: 2011-11-28T08:11:59-07:00
Authentication code: 8675308

Re: Please hELp me to edit this code..

Post 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.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Please hELp me to edit this code..

Post 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.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Please hELp me to edit this code..

Post 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'>";
Post Reply