首页 文章

如何从php中的ImageMagick转换命令获取图像blob

提问于
浏览
0

通过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而不是写入文件,我的问题将得到解决 .

1 回答

  • 1

    附加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);

相关问题