1
votes

Im using PHP Imagick to process images, I need to convert an EPS file into PNG file and next the remaining code can process the created PNG, Im able to convert EPS as PNG and can process to, but when i do this the PNG file is creating with white background, I want it to be transparent where EPS file is not having any background either. My code is as follows

$img = new Imagick();
$img->setResolution(300,300);
$img->readImage('my_file.eps); //reading the file
$img->setBackgroundColor ('#623423'); //setting background color but not working
$img->setImageFormat("png"); //setting the format to save//converting
$img->writeImage('converted.png'); //saving the converted file

But the generated png is coming with white bg, can some one help me how to create it with out BG color(transparent)? Thanks in advance!.

1
Could you provide an eps image with transparency? I can not find it out. Have you seen that you are missing a quote after 'my_file.eps?Manolo

1 Answers

0
votes

Have you looked at this example?

<?php

$im = new Imagick();
$im->setBackgroundColor(new ImagickPixel('transparent'));

$im->readImage('carte_Alain2.svg');

$im->setImageFormat("png32");

header('Content-type: image/png');
echo $im;
?>