简体   繁体   中英

How to get image blob from ImageMagick convert command in php

It is possible to get a binary blob by using ImageMagick convert via PHP's shell_exec() . It's very difficult to convert such a command to PHP Imagick class. Is there any alternative way to implement this feature?

I am using Imagick like this.

$im = new Imagick('some image');
$im->trimImage(20000);
header ("Content-Type: image/{$im->getImageFormat()}");
echo $im->getImageBlob(); // need output in from of blob

I want do get output result similar to this.

convert imageName.png -alpha set -   white -border 1 -fill none -fuzz 3% -draw "color 0,0 floodfill" -shave 1x1 removed_edges.png

If ImageMagick command returns a binary blob instead of writing to a file, my problems will be solved.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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