可以通过PHP的
shell_exec()
使用ImageMagick convert
来获取二进制blob。将这样的命令转换为 PHP Imagick 类是非常困难的。有没有其他方法来实现此功能?我像这样使用Imagick。
$im = new Imagick('some image');
$im->trimImage(20000);
header ("Content-Type: image/{$im->getImageFormat()}");
echo $im->getImageBlob(); // need output in from of blob
我想得到与此类似的输出结果。
convert imageName.png -alpha set - white -border 1 -fill none -fuzz 3% -draw "color 0,0 floodfill" -shave 1x1 removed_edges.png
如果 ImageMagick 命令返回二进制 blob 而不是写入文件,我的问题将得到解决。
在命令之后附加 jpg:- 而不是图像名称,它正在工作。
$command = "convert imageName.png -alpha set - white -border 1 -fill none -fuzz 3% -draw "color 0,0 floodfill" -shave 1x1 jpg:-";
header ("Content-Type: image/jpg");
echo shell_exec($command);