label not generating

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
mahadazad
Posts: 12
Joined: 2012-04-18T21:14:05-07:00
Authentication code: 13

label not generating

Post by mahadazad »

hi,
I am trying to generate text with rotation, no background color, and not defining the size. The command which i am using is working fine on my windows machine:

C:/im/convert -background none label:"fsdfds" -fill #ff0000 -font Arial -pointsize 12 C:/public_html/text.png

but the same command on my server which is on linux is not working (not generating any image):
/usr/bin/convert -background none label:"fsdfds" -fill #ff0000 -font Arial -pointsize 12 /home/public_html/text.png

not even this:
/usr/bin/convert label:"fsdfds" -fill #ff0000 -font Arial -pointsize 12 /home/public_html/text.png
/usr/bin/convert -background none label:"fsdfds" -font Arial -pointsize 12 /home/public_html/text.png

but however this works:
/usr/bin/convert label:"fsdfds" -font Arial -pointsize 12 /home/public_html/text.png


I have referred the documentation the syntax is correct but i cant figureout the reason of its failure. I can not see any error messages as i am using PHP to use this command as a system call, and it does not give any errors.

please help

thank you
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: label not generating

Post by fmw42 »

specify all the settings before the label:

convert -background none -fill #ff0000 -font Arial -pointsize 12 label:"fsdfds" C:/public_html/text.png

In many cases IM processes from left to right, so settings need to be specified before the command.
mahadazad
Posts: 12
Joined: 2012-04-18T21:14:05-07:00
Authentication code: 13

Re: label not generating

Post by mahadazad »

ok i tried this but did not work as well:

/usr/bin/convert -background none -fill #ff0000 -font Arial -pointsize 12 label:"fsdfds" /home/public_html/svg/text.png
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: label not generating

Post by Bonzo »

Try this to see if you get any errors:

Code: Select all

<?php
$array=array(); 
echo "<pre>"; 
exec("/usr/bin/convert -background none -fill #ff0000 -font Arial -pointsize 12 label:"fsdfds" /home/public_html/svg/text.png 2>&1", $array);  
echo "<br>".print_r($array)."<br>";  
echo "</pre>"; 
?>
mahadazad
Posts: 12
Joined: 2012-04-18T21:14:05-07:00
Authentication code: 13

Re: label not generating

Post by mahadazad »

empty array

array ()
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: label not generating

Post by Bonzo »

Just seen an error in my code as I should have escaped the " around the text:

Code: Select all

<?php
$array=array(); 
echo "<pre>"; 
exec("/usr/bin/convert -background none -fill #ff0000 -font Arial -pointsize 12 label:\"fsdfds\" /home/public_html/svg/text.png 2>&1", $array);  
echo "<br>".print_r($array)."<br>";  
echo "</pre>"; 
?>
Its strange you are not getting and error; I will have to try it when I get home.
mahadazad
Posts: 12
Joined: 2012-04-18T21:14:05-07:00
Authentication code: 13

Re: label not generating

Post by mahadazad »

ya i escaped at my side. But i dont know why i am getting an empty array and its not generating anything if i put '-background none -fill #ff0000'
mahadazad
Posts: 12
Joined: 2012-04-18T21:14:05-07:00
Authentication code: 13

Re: label not generating

Post by mahadazad »

ok i fixed the problem myself. the problem was with fill I had to put it in quotes like "#ff0000"

so its working now:

/usr/bin/convert -background none label:"hello" -fill "#ff0000" -font Arial -pointsize 12 /home/public_html/text.png
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: label not generating

Post by anthony »

Remember when PHP executes a string....

PHP does its quotes, backslash and variable substitutions

Shell then splits up arguments and does its own variable and quote substitutions
and also does the "2>&1" file descriptor redirections (so PHP can read the errors on stdout)

ImageMagick gets a argument array, but will also do its own filename meta-character handling
specifically for DOS (the dos environment doesn't handle meta-chars) and for arguments such as
coder:*.gif[50x50] which the shell fails to expand due to coder: prefix or the [...] read modifier.

That is a LOT of argument parsing!

See IM examples PHP Shell
http://www.imagemagick.org/Usage/api/#php_example
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply