简体   繁体   中英

php ImageMagick exec -draw text doesn't work as expected - special characters

exec($IM_path."convert
    -size 800x300 xc:black  
    -font ".$linktottf."
    -pointsize 16
    -draw \"fill white stroke none decorate underline text 580,28 Kühle Frische, not working\"
    output.png");

The "draw text"-part in the code above doesn't work. the output.png displays only "Khle" … so there must be a problem with Special Characters, Whitespaces, Quotes, …

I tried a lot (escaping, different quotes, backslashes, …)

I've lost a lot of time now … so this is why I hope you could help me. Thx!

if you want the quotes drawn as well you need to enclose them in a different set of quotes, double quotes wrapped in single quotes.

label:'\"fill white stroke none decorate underline text 580,28 Kühle Frische, not working\"'

As for the special characters try saving your script in unix utf-8 format (editors like Textpad have options for saving files as these when showing the save dialog, similar editors should have the same option).

And set the system LANG to use utf

LANG=en_US.utf-8;

exec("LANG=en_US.utf-8; ".$IM_path."convert -size 800x300 xc:black -font ".$linktottf." -pointsize 16 label:'\"fill white stroke none decorate underline text 580,28 Kühle Frische, not working\"' output.png");

Looks like you want 'label' and not draw. also it needs to be on one line otherwise it will interpret it as separate commands

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM