如何从 php 中的 ImageMagick 转换命令获取图像 blob
How to get image blob from ImageMagick convert command in php
可以通过 PHP 的 shell_exec()
使用 ImageMagick convert
获取二进制 blob。很难将这样的命令转换为 PHP Imagick class。有没有其他方法可以实现此功能?
我是这样使用 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 命令 returns 二进制 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);
可以通过 PHP 的 shell_exec()
使用 ImageMagick convert
获取二进制 blob。很难将这样的命令转换为 PHP Imagick class。有没有其他方法可以实现此功能?
我是这样使用 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 命令 returns 二进制 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);