ImagickDemos icon indicating copy to clipboard operation
ImagickDemos copied to clipboard

Convert jpg image to transparent png image using Imagick

Open CHANDRA-BHUSHAN-SAH opened this issue 8 years ago • 0 comments

Hello, I want to convert a jpg image file to transparent png image file for this I am using ImageMagick commands as follows

  1. convert original.jpg -fuzz 2% -transparent white fuz.png
  2. convert fuz.png -fx 'a==0 ? HotPink : u' tmp.png
  3. convert tmp.png ( +clone -fx 'p{0,0}' ) -compose Difference -composite -modulate 100,0 -alpha off dif.png
  4. convert dif.png -bordercolor black -border 2 -threshold 2% -blur 0x3 msk.png
  5. convert original.jpg -bordercolor white -border 2 msk.png -alpha Off -compose CopyOpacity -composite target.png

In these commands "original.jpg" is the original image and "target.png" is the required png image. By using these commands I am able to do what I required but I want to do the same in PHP using Imagick.

So, please anybody provide the Imagick php code for the same.

Thank

CHANDRA-BHUSHAN-SAH avatar Mar 18 '16 12:03 CHANDRA-BHUSHAN-SAH