gpt4 book ai didi

svg - 为什么在 PHP 中使用 ImageMagick 将 SVG 光栅化为 PNG 时会得到 NoDecodeDelegateForThisImageFormat?

转载 作者:行者123 更新时间:2023-12-04 20:21:39 24 4
gpt4 key购买 nike

我正在尝试使用以下代码将 svg 图像转换为 png:

$image = new Imagick();
$image->readImageBlob($_POST['svgcode']);
$image->setImageFormat("png24");
$image->resizeImage(600, 600, imagick::FILTER_LANCZOS, 1);
header('Content-type: image/png');
echo $image;

但是第二行有错误:
NoDecodeDelegateForThisImageFormat `' @ error/blob.c/BlobToImage/361

我怎样才能解决这个问题?

最佳答案

svg 的第一行必须是 <?xml version="1.0" encoding="UTF-8" standalone="no"?>

$svg = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>'.$svg;

这样做,你会很享受:-)

关于svg - 为什么在 PHP 中使用 ImageMagick 将 SVG 光栅化为 PNG 时会得到 NoDecodeDelegateForThisImageFormat?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18661811/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com