如何在PHP中运行Imagemagick命令?

4
我需要将文本弯曲并放置在另一张图片上。我从他们的网站上得到了下面提到的代码,但它不起作用;请问有人知道我如何在PHP中实现这个功能。我的系统支持ImageMagick并已启用。
以下是代码:
convert ( newmug1.jpg -thumbnail 200x200 -write mpr:image +delete ) \ ( -pointsize 20 -fill red -background none label:"Cottenham horse show" -virtual-pixel transparent -distort arc 120 -write mpr:arc +delete ) \ mpr:image mpr:arc -gravity north -composite combined.jpg
请帮忙,谢谢!
此致
敬礼
Tismon

1
请参考以下链接,了解如何在PHP中运行ImageMagick命令:http://stackoverflow.com/questions/2873306/how-to-run-imagemagik-commands-in-php - JoseK
1
PHP有一个ImageMagick扩展。更多详情请参阅手册 - Andy E
你得到正确的答案了吗? - GauravSTomar
2个回答

7

使用exec命令 - http://php.net/manual/en/function.exec.php

exec('convert ( newmug1.jpg -thumbnail 200x200 -write mpr:image +delete ) \ ( -pointsize 20 -fill red -background none label:"Cottenham horse show" -virtual-pixel transparent -distort arc 120 -write mpr:arc +delete ) \ mpr:image mpr:arc -gravity north -composite combined.jpg');

谢谢回复,但对我没有用。我已经将“exec”更改为“system”,但这也失败了。这是我使用的代码<?php system("convert ( newmug1.jpg -thumbnail 200x200 -write mpr:image +delete ) \ ( -pointsize 20 -fill red -background none label:'Cottenham horse show' -virtual-pixel transparent -distort arc 120 -write mpr:arc +delete ) \ mpr:image mpr:arc -gravity north -composite combined.jpg"); ?> - tismon
将命令用单引号 ' 包裹起来,而不是双引号 ",因为命令中已经有一个双引号。 - Lizard

0

尝试使用这个

exec("<full path to binary> '-dNOPAUSE' '-sDEVICE=jpeg' '-r<resolution>'
     '-g<dimensions' '-dUseCIEColor' '-dTextAlphaBits=4' '-dGraphicsAlphaBits=4'
     '-o<where you want the image stored>' '-dJPEGQ=<quality - I used 90>'
     '<pdf file to resize>'", $outputArray);

如果使用变量填充占位符,像$resolution这样的变量会直接进入命令,例如-r$resolution

您可能还会发现网站对您有所帮助。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接