gpt4 book ai didi

php - 将带过滤器的 SVG 图像转换为 PNG/PDF

转载 作者:行者123 更新时间:2023-12-05 06:47:09 25 4
gpt4 key购买 nike

我有以下 svg 图像到 png 图像和 pdf 图像,分辨率为 300 DPI。

<svg width="640" height="480" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Created with SVG-edit - http://svg-edit.googlecode.com/ -->
<defs>
<filter height="200%" width="200%" y="-50%" x="-50%" id="svg_1_blur">
<feGaussianBlur stdDeviation="10" in="SourceGraphic"/>
</filter>
</defs>
<g>
<title>Layer 1</title>
<image filter="url(#svg_1_blur)" xlink:href="images/logo.png" id="svg_1" height="162.999996" width="223.999992" y="99" x="185"/>
<text xml:space="preserve" text-anchor="middle" font-family="serif" font-size="24" id="svg_2" y="210" x="289" stroke-width="0" stroke="#000000" fill="#000000">sdfdsdsfsdf</text>
</g>
</svg>

我想使用 PHP 执行此操作,我已将滤镜应用于图像的模糊滤镜,我想保留它。

此外,我在 IE 中查看此图像时遇到问题,因为它在 IE9 上不显示模糊效果。有什么建议吗?

最佳答案

您可以使用 GD 的 imagefilter 生成类似的东西:

imagefilter($image_res, IMG_FILTER_GAUSSIAN_BLUR);

imagefilter($image_res, IMG_FILTER_SMOOTH, (int) $levelOfSmoothness);

但是,对于更复杂的 svg,您将需要 SVG renderer .

编辑:

或者,如果您足够了解 convolution matrices :

$gaussian = array(array(1.0, 2.0, 1.0), array(2.0, 4.0, 2.0), array(1.0, 2.0, 1.0));
imageconvolution($image, $gaussian, 16, 0);

关于php - 将带过滤器的 SVG 图像转换为 PNG/PDF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12594668/

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