简体   繁体   English

ImageMagick创建缩略图

[英]ImageMagick creating thumbnail

here is code which creats animated text using imagemagick.. 这是使用imagemagick创建动画文本的代码。

$label=$_POST["label"];
$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 \) ".

the above code wokrs fine when i enter "1234" in label field ... but it doe not when i type"12 34" it displays only "12" it is not taking "space" in between charcter ...something needs to be done for "label" variable.. not sure how to fix this.. please help me to resolve this... 当我在标签字段中输入“ 1234”时,上述代码可以正常工作……但是当我键入“ 12 34”时,它并没有起作用,它仅显示“ 12”,并且字符之间没有空格。完成“标签”变量..不确定如何解决..请帮助我解决此问题...

My post is editted. 我的帖子已编辑。 See what hakre posted, it's a better answer than mine was. 看看臭名昭著,这是比我更好的答案

string escapeshellarg ( string $arg )

Should do the trick, plus it allows you to pass a string directly to the shell function treated as a single safe argument 应该可以解决问题,再加上它允许您将字符串直接传递给作为单个安全参数的shell函数

使用撇号,例如http://www.imagemagick.org/Usage/text/#label中的示例“多行标签”

$cmd = " -background transparent -font $font -pointsize $size label:'$label' -stroke black -strokewidth 2 ".

Put the entire string in double quotes since spaces are not allowed in command line. 将整个字符串放在双引号中,因为命令行中不允许使用空格。 In the following i enclosed both usages of $label in double-quotes using the \\" escape sequence: 在下面的代码中,我使用\\"转义序列将$label两种用法括在双引号中:

$label=$_POST["label"];
$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\" \) ".

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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