更新时间:2023-11-10 19:34:16
检查 ImageMagick 是否安装(可以使用 phpinfo
).如果是,您可以使用以下代码覆盖到 PNG.
Check if ImageMagick is installed (you can find out using phpinfo
). If it is, you can use the following code to cover to a PNG.
$image = new Imagick();
$image->readImageBlob(file_get_contents('image.svg'));
$image->setImageFormat("png24");
$image->resizeImage(1024, 768, imagick::FILTER_LANCZOS, 1);
$image->writeImage('image.png');
有很多讨论这个的线程.特别有用的是这个线程:使用 PHP 将 SVG 图像转换为 PNG
There are many threads that discuss this. One that is particularly useful is this thread: Convert SVG image to PNG with PHP