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?".
sriducati
Posts: 28 Joined: 2011-11-28T08:11:59-07:00
Authentication code: 8675308
Post
by sriducati » 2011-12-30T07:25:28-07:00
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
Post
by Bonzo » 2011-12-30T15:55:47-07:00
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
Post
by sriducati » 2011-12-30T23:05:57-07:00
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
Post
by Bonzo » 2012-01-01T13:05:29-07:00
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
Post
by Bonzo » 2012-01-02T14:23:17-07:00
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'>";