PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, September 19, 2022

[FIXED] How to get image blob from ImageMagick convert command in php

 September 19, 2022     imagemagick, imagemagick-convert, imagick, php     No comments   

Issue

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.


Solution

Appended jpg:- after command instead of image name & it's working.

$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);



Answered By - Sumeet Roy
Answer Checked By - Candace Johnson (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing