PDF to PNG Transparency Problem

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
rananaskar
Posts: 4
Joined: 2015-06-17T07:03:45-07:00
Authentication code: 6789

PDF to PNG Transparency Problem

Post by rananaskar »

I have a pdf which have a transparent background and it also contains a white image, but the problem is when i am removing the background it's removing the white text also.

Here is the code i am using

Code: Select all

$imagename=time().'.png';
$userfile_tmp = $_FILES['image']['tmp_name'];
$im = new Imagick($userfile_tmp);
// $im->flattenImages();
$im->setImageFormat('png');

// $im->paintTransparentImage('white', 0, 10000);

$im->paintTransparentImage($im->getImageBackgroundColor(), 0, 10000);

$im->setImageColorspace(imagick::COLORSPACE_CMYK);

$im->writeImage('pdftopng/'.$imagename);

$run = exec("convert pdftopng/".$imagename." -fill none -draw 'matte 0,0 floodfill' -shave 1x1 pdftopng/".$imagename);
I also tried adding

Code: Select all

-transparent white
but the problem is still remaining.
Post Reply