imagick
imagick copied to clipboard
Imagick svg to png,the png pic has the black border,how to fix?
Imagick svg to png,the png pic has the black border,how to fix? That's the code:
$im = new Imagick($file_name);
$svg = file_get_contents($file_name);
$svg = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>'.$svg;
$im->setBackgroundColor(new ImagickPixel('transparent'));
$im->readImageBlob($svg);
$im->setImageFormat("png24");
$srcImage = $im->getImageGeometry();
$im->resizeImage($srcImage['width'], $srcImage['height'], imagick::FILTER_LANCZOS, 1, false);
$topng_name = date('YmdHis').mt_rand(10000,99999);
$im->writeImage($path.'/'.$topng_name.'.png');
$im->clear();
$im->destroy();
php version:7.2.33 imagick version:3.4.4 Can somebody help me?thank you...
Please can you post the SVG you are trying with?
ok
That seems to be converted correctly for me. Please can you:
i. Post the output image you are getting that you think is wrong.
ii. Says which version of ImageMagick you have on your system. That will be in the phpinfo page.
ok i.You can see the png image has black border everywhere ii.Imagick version:3.4.4


That seems to be converted correctly for me. Please can you:
i. Post the output image you are getting that you think is wrong.
ii. Says which version of ImageMagick you have on your system. That will be in the phpinfo page.
ok,i post the image :)
Yeah, I get that result when using ImageMagick 6.9.10-23.
Upgrading to ImageMagick 6.9.12-58 and recompiling Imagick makes the output image look as you would expect it.
ok,thank you very much,bro.