imagick icon indicating copy to clipboard operation
imagick copied to clipboard

Imagick svg to png,the png pic has the black border,how to fix?

Open wilsonchen85 opened this issue 3 years ago • 7 comments

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...

wilsonchen85 avatar Aug 08 '22 14:08 wilsonchen85

Please can you post the SVG you are trying with?

Danack avatar Aug 08 '22 14:08 Danack

ok

2022080823333080389

wilsonchen85 avatar Aug 08 '22 15:08 wilsonchen85

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.

Danack avatar Aug 08 '22 16:08 Danack

ok i.You can see the png image has black border everywhere ii.Imagick version:3.4.4

2022080921171073290

11111

wilsonchen85 avatar Aug 09 '22 13:08 wilsonchen85

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 :)

wilsonchen85 avatar Aug 10 '22 13:08 wilsonchen85

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.

Danack avatar Aug 11 '22 04:08 Danack

ok,thank you very much,bro.

wilsonchen85 avatar Aug 12 '22 13:08 wilsonchen85